예제 #1
0
파일: detail.php 프로젝트: sQcrm/sqcrm
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Detail page 
* @author Abhik Chakraborty
*/
$do_crmfields = new CRMFields();
$do_block = new Block();
$do_block->get_block_by_module($module_id);
$module_obj = new Calendar();
$module_obj->getId($sqcrm_record_id);
//updates detail, just add and last updated
$do_crmentity = new CRMEntity();
$update_history = $do_crmentity->get_last_updates($sqcrm_record_id, $module_id, $module_obj);
// Recurrent events info
$recurrent_events = new RecurrentEvents();
$recurrent_events_pattern = $recurrent_events->has_recurrent_events($sqcrm_record_id);
if (false !== $recurrent_events_pattern) {
    $recurrent_events_pattern = json_decode($recurrent_events_pattern, true);
}
$text_options = $recurrent_events->get_text_options();
$days_in_week = $recurrent_events->get_days_in_week();
//event reminder info
$do_events_reminder = new EventsReminder();
$reminder = $do_events_reminder->get_event_reminder($sqcrm_record_id);
if (isset($_GET['ajaxreq']) && $_GET['ajaxreq'] == true) {
    require_once 'view/detail_view_entry.php';
} else {
    require_once 'view/detail_view.php';
}
예제 #2
0
 /**
  * Event function to update the data
  * @param object $evctl
  */
 public function eventEditRecord(EventControler $evctl)
 {
     $permission = $_SESSION["do_crm_action_permission"]->action_permitted('edit', 2, (int) $evctl->sqrecord);
     if (true === $permission) {
         $do_process_plugins = new CRMPluginProcessor();
         // process before update plugin. If any error is raised display that.
         $do_process_plugins->process_action_plugins((int) $evctl->idmodule, $evctl, 3, (int) $evctl->sqrecord, (object) $this->getId((int) $evctl->sqrecord));
         if (strlen($do_process_plugins->get_error()) > 2) {
             $_SESSION["do_crm_messages"]->set_message('error', $do_process_plugins->get_error());
             $next_page = NavigationControl::getNavigationLink($evctl->module, "edit");
             $dis = new Display($next_page);
             $dis->addParam("sqrecord", (int) $evctl->sqrecord);
             if ($evctl->return_page != '') {
                 $dis->addParam("return_page", $evctl->return_page);
             }
             $evctl->setDisplayNext($dis);
         } else {
             $do_crm_fields = new CRMFields();
             $fields = $do_crm_fields->get_field_information_by_module_as_array((int) $evctl->idmodule);
             // edit the event
             $idevents = $this->edit_event($evctl, $fields);
             if (false === $idevents) {
                 // if error re-direct
                 $next_page = $evctl->error_page;
                 $dis = new Display($next_page);
                 $evctl->setDisplayNext($dis);
             } else {
                 $do_recurrent_event = new RecurrentEvents();
                 $has_recurrent_events = $do_recurrent_event->has_recurrent_events($idevents);
                 if ($evctl->event_repeat == 'on') {
                     $recurrent_dates = $do_recurrent_event->get_recurrent_dates($evctl);
                     $recurrent_pattern = $do_recurrent_event->get_recurrent_event_pattern();
                     if (is_array($recurrent_dates) && count($recurrent_dates) > 0) {
                         $add_recurrent_events = false;
                         // if existing recurrent events found and its not eqaul to the submitted one
                         if (false !== $has_recurrent_events && trim(json_encode($recurrent_pattern)) != trim($has_recurrent_events)) {
                             $this->delete_related_recurrent_events($idevents);
                             $do_recurrent_event->delete_recurrent_pattern($idevents);
                             $add_recurrent_events = true;
                         } elseif ($has_recurrent_events === false) {
                             $add_recurrent_events = true;
                         }
                         if (true === $add_recurrent_events) {
                             foreach ($recurrent_dates as $recurrent_dates) {
                                 $idevents_rec = $this->add_events($evctl, $fields);
                                 $qry = "\n\t\t\t\t\t\t\t\t\tupdate " . $this->getTable() . " set \n\t\t\t\t\t\t\t\t\t`start_date` = ?, \n\t\t\t\t\t\t\t\t\t`end_date` = ?,\n\t\t\t\t\t\t\t\t\t`parent_recurrent_event_id` = ? \n\t\t\t\t\t\t\t\t\twhere `idevents` = ?";
                                 $stmt = $this->getDbConnection()->executeQuery($qry, array($recurrent_dates, $recurrent_dates, $idevents, $idevents_rec));
                             }
                             $this->insert('recurrent_events', array('idevents' => $idevents, 'recurrent_pattern' => json_encode($recurrent_pattern)));
                         }
                     }
                 } else {
                     if (false !== $recurrent_pattern) {
                         $this->delete_related_recurrent_events($idevents);
                         $do_recurrent_event->delete_recurrent_pattern($idevents);
                     }
                 }
                 // Event reminder
                 $do_events_reminder = new EventsReminder();
                 if ($evctl->event_alert == 'on') {
                     $do_events_reminder->update_event_reminder($idevents, $evctl);
                 } else {
                     if (false !== $do_events_reminder->get_event_reminder($idevents)) {
                         $do_events_reminder->delete_event_reminder($idevents);
                     }
                 }
                 // process after update plugin
                 $do_process_plugins->process_action_plugins((int) $evctl->idmodule, $evctl, 4, $idevents, (object) $this->getId($idevents));
                 $next_page = NavigationControl::getNavigationLink($evctl->module, "detail");
                 $dis = new Display($next_page);
                 $dis->addParam("sqrecord", $idevents);
                 $evctl->setDisplayNext($dis);
             }
         }
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('You do not have permission to edit the record ! '));
         $next_page = NavigationControl::getNavigationLink($evctl->module, "list");
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     }
 }