Created
December 15, 2018 22:04
-
-
Save FredAzevedo/6850c5d9176fbaa49abf13b49024f5e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Adianti\Control\TAction; | |
use Adianti\Database\TCriteria; | |
use Adianti\Database\TFilter; | |
use Adianti\Registry\TSession; | |
use Adianti\Widget\Util\TFullCalendar; | |
class AgendamentoOs extends TPage | |
{ | |
private $ag; | |
public function __construct() | |
{ | |
parent::__construct(); | |
$this->ag = new FFullCalendarOs(date('Y-m-d'), 'month'); | |
$this->ag->id = 'calendarOs'; | |
$this->ag->setReloadAction(new TAction(array($this, 'getEvents'))); | |
$this->ag->setDayClickAction(new TAction(array('OsForm', 'onEdit'))); | |
$this->ag->setEventClickAction(new TAction(array('OsForm', 'onEdit'))); | |
$this->ag->setEventUpdateAction(new TAction(array('OsForm', 'onUpdateEvent'))); | |
$this->ag->setCustomButtonInfo('Filtros', 'AgendamentoOsFiltros'); | |
//$this->ag->disableDragging(); | |
//$this->ag->disableResizing(); | |
parent::add( $this->ag ); | |
} | |
public static function getEvents($param=NULL) | |
{ | |
$return = array(); | |
try | |
{ | |
TTransaction::open('sample'); | |
$repos = new TRepository('Os'); | |
$cri = new TCriteria(); | |
$situacao = TSession::getValue('agendamento_os_situacao_id'); | |
$cliente_id = TSession::getValue('agendamento_os_cliente_id'); | |
$user_id = TSession::getValue('agendamento_os_user_id'); | |
if ($situacao) { | |
$cri->add(new TFilter('situacao', '=', $situacao)); | |
} | |
if ($cliente_id) { | |
$cri->add(new TFilter('cliente_id', '=', $cliente_id)); | |
} | |
if ($user_id) { | |
$cri->add(new TFilter('user_id', '=', $user_id)); | |
} | |
$events = $repos->load($cri); | |
if ($events) | |
{ | |
foreach ($events as $event) | |
{ | |
$event_array = $event->toArray(); | |
$event_array['start'] = str_replace( ' ', 'T', $event_array['dataAbertura']); | |
$event_array['end'] = str_replace( ' ', 'T', $event_array['dataPrevisao']); | |
$popover_content = $event->render(" | |
<b>Nº da OS:</b> {id} | |
<br><b>Supervisor / Consultor:</b> {system_user->name} | |
<br><b>Cliente / Razão Social:</b> {cliente->razao_social} | |
<br><b>Observações:</b> {observacao} | |
<br><b>Situação/Status da OS:</b> {servicoStatus->descricao} | |
"); | |
$event_array['title'] = TFullCalendar::renderPopover($event->cliente->nome_fantasia, 'Obs. Agendamento', $popover_content); | |
$return[] = $event_array; | |
} | |
} | |
TTransaction::close(); | |
echo json_encode($return); | |
} | |
catch (Exception $e) | |
{ | |
new TMessage('error', $e->getMessage()); | |
} | |
} | |
/** | |
* Reconfigure the callendar | |
*/ | |
public function onReload($param = null) | |
{ | |
if (isset($param['view'])) | |
{ | |
$this->ag->setCurrentView($param['view']); | |
} | |
if (isset($param['date'])) | |
{ | |
$this->ag->setCurrentDate($param['date']); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment