public function submitoperatorcommentAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $model = new Gyuser_Model_CRMTasks(); try { $operator_id = $model->operator_id; $constants = new Gyuser_Model_CrmConstants(); $operatorArray = $constants->getOperators(); $client_id = $_POST['client_id']; $comment = $_POST['comment']; $model->insertOperatorComment($client_id, $comment); $return['status'] = 'success'; $return['html'] = '<li> <h2>Comentario <span class="action-date">' . date('H:i:s') . '</span></h2> <p>' . $comment . ' <span class="action-operator">' . $operatorArray[$operator_id] . '</span></p> </li>'; } catch (Exception $e) { $return['status'] = 'error'; $return['message'] = $e; } echo json_encode($return); }
public function createDailyTasks() { $constants = new Gyuser_Model_CrmConstants(); $event_typeArray = $constants->getEventTypes(); $event_actionArray = $constants->getEventActions(); $eventUnitArray = $constants->getSpanUnit(); $operatorArray = $constants->getOperators(); $operatorTypeArray = $constants->getOperatorTypes(); $query = "SELECT * FROM CRM_Events WHERE status = 1 ORDER BY event_type"; $db = Zend_Db_Table::getDefaultAdapter(); $stmt = $db->query($query); $rows = $stmt->fetchAll(); $INSERT = FALSE; if (count($rows) > 0) { foreach ($rows as $event) { $eventId = $event['id']; $DATE = date('Y-m-d', strtotime($constants->getEventTypeSign($event['event_type']) . ' ' . $event['event_span_count'] . ' ' . $event['event_span_unit'])); // DELETE LATER //$DATE = date('Y-m-d' ,strtotime($DATE . " - $window DAY")); // 1 = 'Follow up potencial'; // 2 = 'Follow up pasivo'; // 3 = 'Payment due'; $data['event_id'] = $event['id']; $data['event_type'] = $event['event_type']; $data['operator_type'] = $event['operator_id']; $data['event_action'] = $event['event_action']; $data['operator_id'] = 0; $data['client_id'] = ''; $data['status'] = 0; $data['extra'] = ''; $data['ref_date'] = date('Y-m-d'); $data['due_date'] = date('Y-m-d'); switch ((int) $event['event_type']) { case 1: //seguimiento a cliente potencial $query = "SELECT id, DATE(type_change) AS the_date FROM clients WHERE client_type IN (1,2) AND DATE(type_change) = '{$DATE}' AND status = 1"; break; case 2: //seguimiento a cliente pasivo $query = "SELECT id, DATE(type_change) AS the_date FROM clients WHERE client_type = 5 AND DATE(type_change) = '{$DATE}' AND status = 1"; break; case 3: //seguimiento a cliente activo $query = "SELECT id, DATE(type_change) AS the_date FROM clients WHERE client_type = 3 AND DATE(type_change) = '{$DATE}' AND status = 1"; break; case 4: //seguimiento a cliente en cobranza $query = "SELECT id, DATE(type_change) AS the_date FROM clients WHERE client_type = 4 AND DATE(type_change) = '{$DATE}' AND status = 1"; break; case 5: //seguimiento por recordatorio de pago $query = "SELECT C.date, C.check_n, C.amount, O.client_id FROM cheques AS C JOIN operations AS O ON (C.operation_id = O.id) WHERE C.date = '{$DATE}' "; break; } $stmt = $db->query($query); $clients = $stmt->fetchAll(); if (count($clients) > 0) { foreach ($clients as $client) { if ($event['event_type'] == 5) { //recordatorio de pago $data['client_id'] = $client['client_id']; $data['ref_date'] = $client['date']; $data['extra'] = 'Cheque N' . $client['check_n'] . ' ' . $client['date'] . ' $' . $client['amount']; } else { $data['client_id'] = $client['id']; $data['ref_date'] = $client['the_date']; } $db->insert('Notifications', $data); } } echo var_dump($data) . '<br/><br/>'; } } }
public function getClientHistory($id) { $constants = new Gyuser_Model_CrmConstants(); $event_typeArray = $constants->getEventTypes(); $event_actionArray = $constants->getEventActions(); $eventUnitArray = $constants->getSpanUnit(); $operatorArray = $constants->getOperators(); $operatorTypeArray = $constants->getOperatorTypes(); $list = false; $stmt = $this->db->query("SELECT * FROM Notifications WHERE client_id = {$id} AND action_date IS NOT NULL ORDER BY action_date DESC,due_date"); $notifications = $stmt->fetchAll(); if (count($notifications) > 0) { foreach ($notifications as $notification) { $dias = array('Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado', 'Domingo'); $meses = array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'); $datetime = strtotime($notification['action_date']); $numDia = date('N', $datetime) - 1; $numMes = date('n', $datetime) - 1; $dia = $dias[$numDia]; $mes = $meses[$numMes]; $dateFormat = $dia . ' ' . date('j', $datetime) . ' de ' . $mes; if ((int) date('Y', $datetime) < (int) date('Y')) { $dateFormat .= ' de ' . date('Y', $datetime); } $list[$notification['id']]['status'] = $notification['status']; //$list[$notification['id']]['action_date'] = date('D, M j H:i', strtotime($notification['action_date'])); $list[$notification['id']]['action_date'] = $dateFormat; $list[$notification['id']]['due_date'] = date('D, M j', strtotime($notification['due_date'])); $list[$notification['id']]['ref_date'] = date('D, M j', strtotime($notification['ref_date'])); $list[$notification['id']]['comment'] = $notification['comment']; $list[$notification['id']]['extra'] = $notification['extra']; if (isset($notification['event_type'])) { //if($notification['event_type'] > 0) $list[$notification['id']]['title'] = $event_typeArray[$notification['event_type']] . '(' . $event_actionArray[$notification['event_action']] . ')'; } else { $list[$notification['id']]['title'] = $notification['title']; } $list[$notification['id']]['operator'] = $operatorArray[$notification['operator_id']]; } } return $list; }