Exemple #1
0
// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Cronjob to send event reminder
* Usually it should run every minute round the clock.
* $GLOBALS['cfg_full_path'] is the path to the CRM root so that the cron job could be 
* set outside web access directory which is recomended
* TODO : 
* In the current version it does not care about the individual user time zone before sending the email
* So in the future version need to implement the code such that emails are send as per the user timezone
* @author Abhik Chakraborty
*/
$GLOBALS['cfg_full_path'] = '/var/www/sqcrm/';
include_once $GLOBALS['cfg_full_path'] . 'config.php';
$email_template = new EmailTemplate("event_reminder");
$emailer = new SQEmailer();
$do_event_reminder = new EventsReminder();
$do_event_reminder->get_reminder_emails_to_send();
$do_calendar = new Calendar();
$now = date("Y-m-d H:i:s");
if ($do_event_reminder->getNumRows() > 0) {
    while ($do_event_reminder->next()) {
        $d = $do_event_reminder->days;
        $h = $do_event_reminder->hours;
        $m = $do_event_reminder->minutes;
        if (strlen($do_event_reminder->email_ids) > 3) {
            $additional_email = explode(",", $do_event_reminder->email_ids);
            if (is_array($additional_email) && count($additional_email) > 0) {
                $email_to_array = array();
                $email_to_array[0] = $additional_email;
            }
        } else {
Exemple #2
0
<?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';
}
Exemple #3
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);
     }
 }