示例#1
0
 /**
  * function to load the queues 
  * @param integer $iduser
  * @return array
  */
 public function get_all_queue($iduser = 0)
 {
     if ((int) $iduser == 0) {
         $iduser = $_SESSION['do_user']->iduser;
         $user_timezone = $_SESSION['do_user']->user_timezone;
     } else {
         $do_user = new User();
         $do_user->getId($iduser);
         $user_timezone = $do_user->user_timezone;
     }
     $today = TimeZoneUtil::get_user_timezone_date($user_timezone);
     $security_where = $_SESSION["do_crm_action_permission"]->get_user_where_condition('q', 18, false, $iduser);
     $qry = "\n\t\tselect \n\t\tq.*,\n\t\tm.name as module_name,\n\t\tm.module_label\n\t\tfrom queue q\n\t\tinner join module m on m.idmodule = q.related_module_id\n\t\twhere \n\t\t1=1\n\t\t" . $security_where . "\n\t\tand q.queue_date >= ?\n\t\torder by q.queue_date,q.related_module_id\n\t\t";
     $this->query($qry, array($today));
     $return_array = array();
     if ($this->getNumRows() > 0) {
         $todayDateObj = new DateTime($today);
         $do_crm_entity = new CRMEntity();
         while ($this->next()) {
             $queueDateObj = new DateTime($this->queue_date);
             $diff = $todayDateObj->diff($queueDateObj);
             $day_diff = $diff->format('%R%a');
             $data = array("idqueue" => $this->idqueue, "sqcrm_record_id" => $this->sqcrm_record_id, "module_name" => $this->module_name, "module_label" => $this->module_label, "idmodule" => $this->related_module_id, "entity_identifier" => $do_crm_entity->get_entity_identifier($this->sqcrm_record_id, $this->module_name));
             if ($day_diff == 0) {
                 $return_array["today"][] = $data;
             } elseif ($day_diff == 1) {
                 $return_array["tomorrow"][] = $data;
             } elseif ($day_diff > 1) {
                 $return_array["later"][] = $data;
             }
         }
     }
     return $return_array;
 }
    /**
     * event function to load the recently viewed infomation
     * @param object $evctl
     * @return string html
     */
    function eventAjaxLoadRecentlyViewed(EventControler $evctl)
    {
        $html = '';
        $iduser = $_SESSION["do_user"]->iduser;
        $this->get_recently_viewed($iduser);
        if ($this->getNumRows() > 0) {
            $do_crm_entity = new CRMEntity();
            $html .= '<ul id="recently_viewed">
						<li><a href="" class="current">' . _('Recently Viewed') . '</a></li>
					';
            while ($this->next()) {
                $identifier = '';
                $record_url = '';
                $module = $_SESSION["do_module"]->modules_full_details[$this->idmodule]["name"];
                $identifier = $do_crm_entity->get_entity_identifier($this->idrecord, $module);
                $record_url = NavigationControl::getNavigationLink($module, "detail", $this->idrecord);
                $html .= '<li><a href="' . $record_url . '">' . $identifier . '</a></li>';
            }
            $html .= '</ul>';
        }
        echo $html;
    }
示例#3
0
 /**
  * function to delete single record from list view and related list view
  * @param object $evctl
  * @return 0 or 1
  * @see view/listview.php
  * @see view/related_listview_entry.php
  */
 function eventAjaxDeleteSingleEntity(EventControler $evctl)
 {
     $referrer = $evctl->referrer;
     if ($referrer == 'list') {
         $module = $evctl->module;
     } elseif ($referrer == 'related') {
         $idrelated_information = (int) $evctl->related_record_id;
         $do_related_information = new CRMRelatedInformation();
         $do_related_information->getId($idrelated_information);
         if ($do_related_information->getNumRows() > 0) {
             $module = $do_related_information->related_module;
         }
     }
     if ($module != '') {
         $module_id = $_SESSION["do_module"]->get_idmodule_by_name($module, $_SESSION["do_module"]);
         $id = (int) $evctl->sqrecord;
         $allow_del = $_SESSION["do_crm_action_permission"]->action_permitted('delete', $module_id, $id);
         if ($allow_del === true) {
             $do_data_history = new DataHistory();
             $crm_entity = new CRMEntity();
             $do_feed_queue = new LiveFeedQueue();
             $do_process_plugins = new CRMPluginProcessor();
             //delete code for the record goes here
             // process before delete plugin
             $do_process_plugins->process_action_plugins($module_id, null, 5, $id);
             if (strlen($do_process_plugins->get_error()) > 2) {
                 echo $do_process_plugins->get_error();
             } else {
                 $this->delete_record($id, $module);
                 $do_data_history->add_history($id, $module_id, 'delete');
                 // Add to feed
                 $feed_other_assigne = array();
                 $entity_assigned_to = $crm_entity->get_assigned_to_id($id, $module);
                 if (is_array($entity_assigned_to) && sizeof($entity_assigned_to) > 0) {
                     if (array_key_exists("idgroup", $entity_assigned_to) && $entity_assigned_to["idgroup"]) {
                         $feed_other_assigne = array("related" => "group", "data" => array("key" => "oldgroup", "val" => (int) $entity_assigned_to["idgroup"]));
                     }
                 }
                 $record_identity = $crm_entity->get_entity_identifier($id, $module);
                 $do_feed_queue->add_feed_queue($id, $module_id, $record_identity, 'delete', $feed_other_assigne);
                 // process after delete plugin
                 $do_process_plugins->process_action_plugins($module_id, null, 5, $id);
                 echo '1';
             }
         } else {
             echo '0';
         }
     } else {
         echo '0';
     }
 }
示例#4
0
    /**
     * function to export list data as PDF
     * @param string $file_name
     * @param array $fields_info
     * @param integer $module_id
     * Library used for PDF generation is tcpdf http://www.tcpdf.org/
     * @see http://www.tcpdf.org/performances.php
     */
    public function export_detail_data_pdf($module, $module_id, $record_id)
    {
        $do_crmfields = new CRMFields();
        $do_block = new Block();
        $do_block->get_block_by_module($module_id);
        $module_obj = new $module();
        $module_obj->getId($record_id);
        if ($module_obj->getNumRows() > 0) {
            $do_crmfields = new CRMFields();
            include_once THIRD_PARTY_LIB_PATH . "/mpdf/mpdf.php";
            $pdf = new mPDF();
            $do_crm_entity = new CRMEntity();
            $entity_identity = $do_crm_entity->get_entity_identifier($record_id, $module, $module_obj);
            $html = '';
            $html .= '<div style="float:left"><h3>' . $entity_identity . '</h3></div><div style="clear:both;"></div>';
            while ($do_block->next()) {
                $html .= '
				<table cellspacing="0" cellpadding="1" border="1" width="800px;">
					<tbody>
						<tr style="background-color:#eeeeee;line-height:100%;">
							<td colspan="4" height="35"><b>' . $do_block->block_label . '</b></td>
						</tr>';
                $do_crmfields->get_form_fields_information($do_block->idblock, $module_id);
                $num_fields = $do_crmfields->getNumRows();
                $tot_count = 0;
                while ($do_crmfields->next()) {
                    $fieldobject = 'FieldType' . $do_crmfields->field_type;
                    $fields_count++;
                    $tot_count++;
                    if ($tot_count == 1 || $tot_count % 2 != 0) {
                        $html .= '<tr>';
                    }
                    $html .= '<td style="background-color:#FDFFBD;width:25%;" height="20">' . $do_crmfields->field_label . '</td>';
                    $fld_name = $do_crmfields->field_name;
                    $field_value = '';
                    if ($do_crmfields->field_type == 12) {
                        $field_value = $fieldobject::display_value($module_obj->{$fld_name}, 'l');
                    } elseif ($do_crmfields->field_type == 11) {
                        $field_value = $fieldobject::display_value($module_obj->{$fld_name}, $module, $sqcrm_record_id, $fld_name, true);
                    } else {
                        $field_value = $do_crmfields->display_field_value($module_obj->{$fld_name}, $do_crmfields->field_type, $fieldobject, $module_obj, $module_id, false);
                    }
                    $html .= '<td height="20" style="width:25%;">' . $field_value . '</td>';
                    if ($tot_count != 1 && $tot_count % 2 == 0) {
                        $html .= '</tr>';
                    }
                    if ($num_fields == $tot_count && $tot_count % 2 != 0) {
                        $html .= '
							<td style="background-color:#FDFFBD;width:25%" height="20">&nbsp;</td>
							<td height="20" style="width:25%">&nbsp;</td>
						</tr>';
                    }
                }
                $html .= '</tbody></table>';
                $html .= '<br>';
            }
            $pdf->WriteHTML($html);
            $pdf->Output($module . '_' . $record_id . '.pdf', 'D');
            exit;
        }
    }
示例#5
0
 /**
  * add feed for the mentioned notes
  * @param integer $idnotes
  * @param string $note_content
  * @param integer $related_module_id
  * @param integer $sqcrm_record_id
  */
 public function add_mentions_feed($idnotes, $note_content, $related_module_id, $sqcrm_record_id)
 {
     if ($idnotes > 0) {
         $mentioned_feed_receiptents = array();
         preg_match_all("/(^|[^@\\w])@(\\w{1,15})\\b/im", $note_content, $mentioned_users);
         if (is_array($mentioned_users) && array_key_exists(2, $mentioned_users) && count($mentioned_users[2]) > 0) {
             $do_user = new \User();
             $active_users = $do_user->get_active_users();
             $current_user = 0;
             $active_users_key_as_username = array();
             foreach ($active_users as $key => $users) {
                 if ($users["iduser"] == $current_user) {
                     continue;
                 }
                 $active_users_key_as_username[$users["user_name"]] = array("iduser" => $users["iduser"], "firstname" => $users["firstname"], "lastname" => $users["lastname"], "email" => $users["email"]);
             }
             foreach ($mentioned_users[2] as $key => $val) {
                 if (array_key_exists($val, $active_users_key_as_username)) {
                     $mentioned_feed_receiptents[] = $active_users_key_as_username[$val["iduser"]];
                 }
             }
             if (is_array($mentioned_feed_receiptents) && count($mentioned_feed_receiptents) > 0) {
                 $do_feed_queue = new \LiveFeedQueue();
                 $do_crm_entity = new \CRMEntity();
                 $do_module = new \Module();
                 $do_module->getId($related_module_id);
                 $identifier = $do_crm_entity->get_entity_identifier($sqcrm_record_id, $do_module->name);
                 $related_identifier_data = array("related_identifier" => '', "related_identifier_idrecord" => $idnotes, "related_identifier_idmodule" => 8);
                 $do_feed_queue->add_feed_queue($sqcrm_record_id, $related_module_id, $identifier, 'note_mention', $mentioned_feed_receiptents, $related_identifier_data);
             }
         }
     }
 }