Example #1
0
 /**
  * function to get the custom view fields information by id
  * @param integer $id 
  * @return mix
  */
 public function get_custom_view_fields_information($id)
 {
     $fields = $this->get_custom_view_fields($id);
     if (false !== $fields) {
         $idmodule = $this->idmodule;
         $do_crm_fields = new CRMFields();
         return $do_crm_fields->get_specific_fields_information($fields, $idmodule, true, 'idfields');
     } else {
         return false;
     }
 }
Example #2
0
 /**
  * function to get the field information for a list view (list,popup,related)
  * gets the object name with the module and the list type and then generates the 
  * persistant object for the module and returns the fields information.
  * @param string $module
  * @param integer $module_id
  * @param string $list_type
  * @return array with the field information
  */
 public function get_listview_field_info($module, $module_id, $list_type, $custom_view_id = 0)
 {
     $object_name = $this->generate_list_view_object_name($module, $list_type);
     $do_list = new $module();
     $do_list->sessionPersistent($object_name, "logout.php", TTL);
     if ((int) $custom_view_id > 0) {
         $do_customview_fields = new CustomViewFields();
         $fields_info = $do_customview_fields->get_custom_view_fields_information($custom_view_id);
     } else {
         // fall back to the module's member property list view field information
         $do_crm_fields = new CRMFields();
         $fields_info = $do_crm_fields->get_specific_fields_information($_SESSION[$object_name]->list_view_fields, $module_id, true);
     }
     $_SESSION[$object_name]->list_view_field_information = $fields_info;
     return $fields_info;
 }
Example #3
0
 /**
  * get the fields by report fields
  * @param integer $idmodule
  * @return array
  */
 public function get_module_fields_for_report($idmodule)
 {
     $do_crm_fields = new CRMFields();
     return $do_crm_fields->get_fieldinfo_grouped_by_block($idmodule, true);
     /*$qry = "
     		select
     		f.idfields,
     		f.field_label,
     		f.field_name,
     		f.idblock,
     		f.field_type,
     		case 
     			when b.block_label <> '' then b.block_label 
     			else 'Other' 
     		end as block_name
     		from fields f
     		left join block b on b.idblock = f.idblock
     		where f.idmodule = ?
     		order by 
     		case when
     		f.idblock <> 0 then 0 else 1 end,
     		b.sequence,
     		f.field_sequence
     		" ;
     		$this->query($qry,array($idmodule));
     		$fields = array();
     		while($this->next()){
     			$fields[$this->idblock][$this->block_name][] = array(
     				"idfields"=>$this->idfields,
     				"field_label"=>$this->field_label,
     				"field_name"=>$this->field_name,
     				"field_type"=>$this->field_type
     			);
     		}
     		return $fields ;*/
 }
Example #4
0
$crm_global_settings = new CRMGlobalSettings();
$currency = $crm_global_settings->get_setting_data_by_name('currency_setting');
$currency_data = json_decode($currency, true);
$report_date_start = '';
$report_date_end = '';
// if submit is clicked with some param then get the values and set to variables
if (isset($_GET['runtime']) && (int) $_GET['runtime'] > 0) {
    $custom_date_filter_values = (int) $_GET['report_date_filter_type_runtime'] == 1 ? true : false;
    $date_filter_type = (int) $_GET['report_date_filter_type_runtime'];
    $report_date_start = isset($_GET['report_date_start_runtime']) ? $_GET['report_date_start_runtime'] : '';
    $report_date_end = isset($_GET['report_date_start_runtime']) ? $_GET['report_date_start_runtime'] : '';
    $selected_user = isset($_GET['report_user_filter_runtime']) ? (int) $_GET['report_user_filter_runtime'] : 0;
}
// p and ptg are table alias names used in the report query
$user_where = $prospect_lost->get_report_where($selected_user, 'p', 'ptg');
$additional_where = $prospect_lost->get_date_filter_where('p', 'expected_closing_date', $date_filter_type, $report_date_start, $report_date_end);
$where = $user_where . $additional_where;
// get the data for the report
$prospect_lost_data_by_amount = $prospect_lost->get_propect_lost_by_amount($where);
$prospect_lost_data_by_no = $prospect_lost->get_propect_lost_by_volume($where);
$prospect_lost->get_detailed_funnel_data('', $selected_user, $date_filter_type, $report_date_start, $report_date_end);
// detailed data fields to be displayed
$detailed_data_fields = array('potential_name', 'potential_type', 'sales_stage', 'lost_reason', 'expected_closing_date', 'assigned_to', 'amount');
$do_crm_fields = new CRMFields();
$fields_info = $do_crm_fields->get_specific_fields_information($detailed_data_fields, 5, true);
// breadcrumbs
$breadcrumb = $prospect_lost->get_breadcrumbs($_GET['path']);
if (false === $custom_date_filter_values) {
    $date_range_display = 'style="display:none;margin-left:3px;"';
}
include_once 'view/report_view.php';
Example #5
0
 /**
  * function to import the data from the csv file
  * @param object $module_object
  * @param integer $start
  * @return boolean
  * loops through the csv data and calls the function import_save() of the module for data insert
  */
 public function import_data($module_object, $start = 0)
 {
     if (is_object($module_object)) {
         $do_crm_fields = new CRMFields();
         //$do_crm_fields->get_field_information_by_module($this->get_import_module_id());
         $crm_fields = $do_crm_fields->get_field_information_by_module_as_array($this->get_import_module_id());
         $upload_path = $GLOBALS['CSV_IMPORT_PATH'];
         $handle = fopen($upload_path . '/' . $this->get_csv_file_name(), "r");
         $lines_count = 0;
         $insert_count = 0;
         $max_insert = $this->get_max_record_insert_per_loop();
         while (($data = fgetcsv($handle, 4096, $this->delimiter)) !== false) {
             if ($lines_count == 0 && $this->get_has_header() === true) {
                 $lines_count++;
                 continue;
             }
             if ($lines_count <= $start) {
                 $lines_count++;
                 continue;
             }
             $lines_count++;
             if ($insert_count == $max_insert) {
                 break;
             }
             $idrecord = $module_object->import_save($this, $crm_fields, $data);
             if ($idrecord !== false) {
                 $insert_count++;
                 // add the record here
                 $this->getDbConnection()->insert($this->getTable(), array("idmodule" => $this->get_import_module_id(), "idrecord" => $idrecord, "date_imported" => date("Y-m-d"), "iduser" => $_SESSION["do_user"]->iduser));
             }
         }
         if ($insert_count > 0) {
             return true;
         } else {
             return false;
         }
     }
 }
Example #6
0
* Gets the module name as a GET and gets the list query for the module
* The fileds information is stored in the memmber array list_view_field_information of the object
* @see view/listview.php
* @author Abhik Chakraborty
*/
include_once "config.php";
$m = $_GET["m"];
$mid = $_GET["mid"];
$module_namespace = $_GET["module_namespace"];
$lp = false;
// if where is already in the query then no need to add the WHERE string
$method_param_used = false;
$module_object_name = $module_namespace . '\\' . $m;
$module_object = new $module_object_name();
$fields = $module_object->list_view_fields;
$do_crmfields = new \CRMFields();
$fields_info = $do_crmfields->get_specific_fields_information($fields, $mid, true);
/**
* FIXME
* For some reason when the array index starts with 0 the text box search works well but the asc/desc on the header does not
* So $aColumns array is used for text search and adding a new array $ahColumns for header sort
*/
$aColumns = array();
$col_count = 0;
foreach ($fields_info as $field_name => $info) {
    $aColumns[$col_count++] = $field_name;
}
$ahColumns = array();
$hcol_count = 0;
foreach ($fields_info as $field_name => $info) {
    $ahColumns[$hcol_count++] = $field_name;
Example #7
0
 }
 if (is_array($mapping_second_row) && sizeof($mapping_second_row) > 0) {
     foreach ($mapping_second_row as $key => $val) {
         if (strlen($val) > 30) {
             $mapping_second_row[$key] = substr($val, 0, 30) . " ...";
         }
     }
 }
 if (is_array($mapping_third_row) && sizeof($mapping_third_row) > 0) {
     foreach ($mapping_third_row as $key => $val) {
         if (strlen($val) > 30) {
             $mapping_third_row[$key] = substr($val, 0, 30) . " ...";
         }
     }
 }
 $do_crmfields = new CRMFields();
 $do_crmfields->get_field_information_by_module($_SESSION["do_import"]->get_import_module_id());
 $module_fields = array();
 while ($do_crmfields->next()) {
     if ($do_crmfields->field_name == 'assigned_to') {
         continue;
     }
     if ($import_module_id == 4) {
         if ($do_crmfields->field_name == 'contact_avatar' || $do_crmfields->field_name == 'portal_user' || $do_crmfields->field_name == 'support_start_date' || $do_crmfields->field_name == 'support_end_date') {
             continue;
         }
     }
     if ($import_module_id == 5) {
         if ($do_crmfields->field_name == 'related_to') {
             $related_to_contact = $do_crmfields->field_label . ' (' . $_SESSION["do_module"]->modules_full_details[4]["name"] . ')';
             $related_to_org = $do_crmfields->field_label . ' (' . $_SESSION["do_module"]->modules_full_details[6]["name"] . ')';
Example #8
0
 /**
  * Constructor function 
  */
 function __construct(sqlConnect $conx = NULL, $table_name = "")
 {
     parent::__construct($conx, $table_name);
 }
$module_id = $_SESSION["do_module"]->get_idmodule_by_name($module, $_SESSION["do_module"]);
$ids = $_GET["chk"];
if (is_array($ids) && count($ids) > 0) {
    // check if record against the module to validate if the user has permission to do a edit
    foreach ($ids as $record_id) {
        $allow_status_change = $_SESSION["do_crm_action_permission"]->action_permitted('edit', $module_id, $record_id);
        if ($allow_status_change === false) {
            break;
        }
    }
    $msg = _('You are trying to change event status for a record, which you are not authorized to.');
} else {
    $msg = _('Please select atleast one record to perform this operation.');
}
if ($allow_status_change === true) {
    $do_fields = new CRMFields();
    $qry = "\n\tselect cv.* \n\tfrom combo_values cv \n\tjoin fields f on f.idfields = cv.idfields \n\twhere \n\tf.field_name='event_status' \n\tand f.table_name='events'\n\torder by cv.sequence\n\t";
    $do_fields->query($qry);
    $e_change = new Event("Calendar->eventChangeEventStatus");
    $e_change->addParam("ids", $ids);
    $e_change->addParam("module", $module);
    $e_change->addParam("module_id", $module_id);
    $e_change->addParam("next_page", NavigationControl::getNavigationLink($obj, $return_page));
    echo '<form class="form-horizontal" id="Calendar__eventChangeEventStatus" name="Calendar__eventChangeEventStatus" action="/eventcontroler.php" method="post">';
    echo $e_change->getFormEvent();
    ?>
<div class="modal-dialog" role="document">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			<h3><span class="label label-info"><?php 
Example #10
0
 /**
  * parse the date filter for the query
  * @param integer $idreport
  * @param array $data
  * @return string
  */
 public function get_parsed_date_filter($idreport, $data = array())
 {
     $date_where = '';
     if (count($data) > 0) {
         $filter_type = $data["filter_type"];
         $do_fields = new CRMFields();
         $do_fields->getId((int) $data["idfield"]);
         $where_field = $do_fields->table_name . '.' . $do_fields->field_name;
         if ($data["start_date"] != '') {
             $start_date = FieldType9::convert_before_save($data["start_date"]);
         }
         if ($data["end_date"] != '') {
             $end_date = FieldType9::convert_before_save($data["end_date"]);
         }
     } else {
         $qry = $this->get_saved_date_filter();
         $this->query($qry, array($idreport));
         if ($this->getNumRows() > 0) {
             $this->next();
             $filter_type = $this->filter_type;
             $field_name = $this->field_name;
             $where_field = $this->table_name . '.' . $field_name;
             if ($this->start_date != '' && $this->start_date != '0000-00-00') {
                 $start_date = $this->start_date;
             }
             if ($this->end_date != '' && $this->end_date != '0000-00-00') {
                 $end_date = $this->end_date;
             }
         }
     }
     if ($filter_type > 0) {
         switch ($filter_type) {
             case '1':
                 if ($start_date != '' && $start_date != '0000-00-00' && $end_date != '' && $end_date != '0000-00-00') {
                     $date_where = " AND " . $where_field . " between '" . $start_date . "' AND '" . $end_date . "'";
                 }
                 break;
             case '2':
                 $date_range = CommonUtils::get_year_date_range('previous');
                 $date_where = " AND " . $where_field . " between '" . $date_range["start"] . "' AND '" . $date_range["end"] . "'";
                 break;
             case '3':
                 $date_range = CommonUtils::get_year_date_range('current');
                 $date_where = " AND " . $where_field . " between '" . $date_range["start"] . "' AND '" . $date_range["end"] . "'";
                 break;
             case '4':
                 $date_range = CommonUtils::get_year_date_range('next');
                 $date_where = " AND " . $where_field . " between '" . $date_range["start"] . "' AND '" . $date_range["end"] . "'";
                 break;
             case '5':
                 $date_range = CommonUtils::get_quarter_date_range('previous');
                 $date_where = " AND " . $where_field . " between '" . $date_range["start"] . "' AND '" . $date_range["end"] . "'";
                 break;
             case '6':
                 $date_range = CommonUtils::get_quarter_date_range('current');
                 $date_where = " AND " . $where_field . " between '" . $date_range["start"] . "' AND '" . $date_range["end"] . "'";
                 break;
             case '7':
                 $date_range = CommonUtils::get_quarter_date_range('next');
                 $date_where = " AND " . $where_field . " between '" . $date_range["start"] . "' AND '" . $date_range["end"] . "'";
                 break;
             case '8':
                 $date_where = " AND " . $where_field . " between concat(date_sub(curdate(),interval 1 day),' 00:00:00') and concat(date_sub(curdate(),interval 1 day),' 23:59:59')";
                 break;
             case '9':
                 $date_where = " AND " . $where_field . " between concat(curdate(),' 00:00:00') and concat(curdate(),' 23:59:59')";
                 break;
             case '10':
                 $date_where = " AND " . $where_field . " between concat(date_add(curdate(),interval 1 day),' 00:00:00') and concat(date_add(curdate(),interval 1 day),' 23:59:59')";
                 break;
             case '11':
                 $date_range = CommonUtils::get_week_date_range('previous');
                 $date_where = " AND " . $where_field . " between '" . $date_range["start"] . "' AND '" . $date_range["end"] . "'";
                 break;
             case '12':
                 $date_range = CommonUtils::get_week_date_range('current');
                 $date_where = " AND " . $where_field . " between '" . $date_range["start"] . "' AND '" . $date_range["end"] . "'";
                 break;
             case '13':
                 $date_range = CommonUtils::get_week_date_range('next');
                 $date_where = " AND " . $where_field . " between '" . $date_range["start"] . "' AND '" . $date_range["end"] . "'";
                 break;
             case '14':
                 $date_range = CommonUtils::get_month_date_range('previous');
                 $date_where = " AND " . $where_field . " between '" . $date_range["start"] . "' AND '" . $date_range["end"] . "'";
                 break;
             case '15':
                 $date_range = CommonUtils::get_month_date_range('current');
                 $date_where = " AND " . $where_field . " between '" . $date_range["start"] . "' AND '" . $date_range["end"] . "'";
                 break;
             case '16':
                 $date_range = CommonUtils::get_month_date_range('next');
                 $date_where = " AND " . $where_field . " between '" . $date_range["start"] . "' AND '" . $date_range["end"] . "'";
                 break;
             case '17':
                 $date_where = " AND " . $where_field . " between date_sub(curdate(),interval 7 day) and date_sub(curdate(),interval 1 day)";
                 break;
             case '18':
                 $date_where = " AND " . $where_field . " between date_sub(curdate(),interval 30 day) and date_sub(curdate(),interval 1 day)";
                 break;
             case '19':
                 $date_where = " AND " . $where_field . " between date_sub(curdate(),interval 60 day) and date_sub(curdate(),interval 1 day)";
                 break;
             case '20':
                 $date_where = " AND " . $where_field . " between date_sub(curdate(),interval 90 day) and date_sub(curdate(),interval 1 day)";
                 break;
             case '21':
                 $date_where = " AND " . $where_field . " between date_add(curdate(),interval 1 day) and date_add(curdate(),interval 7 day)";
                 break;
             case '22':
                 $date_where = " AND " . $where_field . " between date_add(curdate(),interval 1 day) and date_add(curdate(),interval 30 day)";
                 break;
             case '23':
                 $date_where = " AND " . $where_field . " between date_add(curdate(),interval 1 day) and date_add(curdate(),interval 60 day)";
                 break;
             case '24':
                 $date_where = " AND " . $where_field . " between date_add(curdate(),interval 1 day) and date_add(curdate(),interval 90 day)";
                 break;
         }
     }
     return $date_where;
 }
Example #11
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_to_pdf($file_name, $fields_info, $module_id)
 {
     if ($this->getNumRows() > 0) {
         $do_crmfields = new CRMFields();
         include_once THIRD_PARTY_LIB_PATH . "/tcpdf/tcpdf.php";
         $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
         // set default monospaced font
         $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
         // set margins
         $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
         // set auto page breaks
         $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
         // set font
         $pdf->SetFont('helvetica', '', 8);
         // add a page
         $pdf->AddPage();
         $header = '<table><tr>';
         foreach ($fields_info as $field => $info) {
             $header .= '<td><b>' . $info["field_label"] . '</b></td>';
         }
         $header .= '</tr>';
         $pdf->writeHTML($header, true, false, false, false, '');
         while ($this->next()) {
             $data_row = '<table><tr>';
             foreach ($fields_info as $fields => $info) {
                 $fieldobject = 'FieldType' . $info["field_type"];
                 $val = $do_crmfields->display_field_value($this->{$fields}, $info["field_type"], $fieldobject, $this, $module_id, false);
                 $data_row .= '<td>' . $val . '</td>';
             }
             $data_row .= '</tr></table>';
             $pdf->writeHTML($data_row, true, false, false, false, '');
         }
         $pdf->writeHTML('</table>', true, false, false, false, '');
         $pdf->Output($file_name . '.pdf', 'I');
         exit;
     }
 }
Example #12
0
File: add.php Project: sQcrm/sqcrm
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Customview add 
* @author Abhik Chakraborty
*/
$do_crmfields = new CRMFields();
if (isset($_REQUEST["target_module_id"]) && (int) $_REQUEST["target_module_id"] > 0) {
    $target_module_id = (int) $_REQUEST["target_module_id"];
    $cv_fields = $do_crmfields->get_fieldinfo_grouped_by_block($target_module_id, true);
    $date_filters = $do_crmfields->get_date_fields($target_module_id, true);
    $date_filter_options = ViewFilterUtils::get_date_filter_otions();
    $advanced_filter_options = ViewFilterUtils::get_advanced_filter_options();
    require_once 'view/customview_create_view.php';
}
Example #13
0
 /**
  * function to edit the event
  * @param object $evctl
  * @param object $do_crm_fields
  */
 public function edit_event($evctl, $crm_fields)
 {
     $id_entity = (int) $evctl->sqrecord;
     if ($id_entity > 0) {
         $obj = $this->getId($id_entity);
         $obj = (object) $obj;
         // convert the data array to Object
         $table_entity = 'events';
         $table_entity_custom = 'events_custom_fld';
         $table_entity_to_grp = 'events_to_grp_rel';
         $table_entity_related_to = 'events_related_to';
         $entity_data_array = array();
         $custom_data_array = array();
         $assigned_to_as_group = false;
         $related_to_field = false;
         $do_crm_fields = new CRMFields();
         foreach ($crm_fields as $crm_fields) {
             $field_name = $crm_fields["field_name"];
             $field_value = $do_crm_fields->convert_field_value_onsave($crm_fields, $evctl);
             if (is_array($field_value) && count($field_value) > 0) {
                 if ($field_value["field_type"] == 15) {
                     $field_name = 'iduser';
                     $value = $field_value["value"];
                     $assigned_to_as_group = $field_value["assigned_to_as_group"];
                     $group_id = $field_value["group_id"];
                 }
             } else {
                 $value = $field_value;
             }
             if ($crm_fields["table_name"] == $table_entity && $crm_fields["idblock"] > 0) {
                 $entity_data_array[$field_name] = $value;
             }
             if ($crm_fields["table_name"] == $table_entity_custom && $crm_fields["idblock"] > 0) {
                 $custom_data_array[$field_name] = $value;
             }
             if ($crm_fields["table_name"] == $table_entity_related_to && $crm_fields["idblock"] > 0) {
                 if ((int) $field_value > 0) {
                     $related_to_field = true;
                     $related_to = $value;
                     $idmodule_rel_to = $evctl->related_to_opt;
                 }
             }
         }
         $this->update(array("idevents" => $id_entity), $table_entity, $entity_data_array);
         //updating the last_modified,last_modified_by
         $q_upd = "\n\t\t\tupdate `" . $this->getTable() . "` set \n\t\t\t`last_modified` = ? ,\n\t\t\t`last_modified_by` = ?\n\t\t\twhere `" . $this->primary_key . "` = ?";
         $this->query($q_upd, array(date("Y-m-d H:i:s"), $_SESSION["do_user"]->iduser, $id_entity));
         if (count($custom_data_array) > 0) {
             $this->update(array("idevents" => $id_entity), $table_entity_custom, $custom_data_array);
         }
         if ($assigned_to_as_group === false) {
             $qry_grp_rel = "DELETE from `{$table_entity_to_grp}` where `idevents` = ? LIMIT 1";
             $this->query($qry_grp_rel, array($id_entity));
         } else {
             $qry_grp_rel = "select * from `{$table_entity_to_grp}` where `idevents` = ?";
             $this->query($qry_grp_rel, array($id_entity));
             if ($this->getNumRows() > 0) {
                 $this->next();
                 $id_grp_rel = $this->idevents_to_grp_rel;
                 $q_upd = "\n\t\t\t\t\tupdate `{$table_entity_to_grp}` set \n\t\t\t\t\t`idgroup` = ?\n\t\t\t\t\twhere `idevents_to_grp_rel` = ? LIMIT 1";
                 $this->query($q_upd, array($group_id, $id_grp_rel));
             } else {
                 $this->insert($table_entity_to_grp, array("idevents" => $id_entity, "idgroup" => $group_id));
             }
         }
         if ($related_to_field === true) {
             $this->query("select * from `{$table_entity_related_to}` where idevents = ?", array($id_entity));
             if ($this->getNumRows() > 0) {
                 $q_upd = "\n\t\t\t\t\tupdate `{$table_entity_related_to}` set \n\t\t\t\t\t`related_to` = ?,\n\t\t\t\t\t`idmodule` = ?\n\t\t\t\t\twhere `idevents` = ? limit 1 ";
                 $this->query($q_upd, array($related_to, $idmodule_rel_to, $id_entity));
             } else {
                 $this->insert($table_entity_related_to, array("idevents" => $id_entity, "related_to" => $related_to, "idmodule" => $idmodule_rel_to));
             }
         }
         // Record the history
         $do_data_history = new DataHistory();
         $do_data_history->add_history($id_entity, (int) $evctl->idmodule, 'edit');
         $do_data_history->add_history_value_changes($id_entity, (int) $evctl->idmodule, $obj, $evctl);
         //record the feed
         $feed_other_assigne = array();
         if ($assigned_to_as_group === true) {
             $feed_other_assigne = array("related" => "group", "data" => array("key" => "newgroup", "val" => $group_id));
         }
         $do_feed_queue = new LiveFeedQueue();
         $do_feed_queue->add_feed_queue($id_entity, (int) $evctl->idmodule, $evctl->subject, 'edit', $feed_other_assigne);
         $_SESSION["do_crm_messages"]->set_message('success', _('Data updated successfully !'));
         return $id_entity;
     }
 }
Example #14
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;
        }
    }
Example #15
0
 /**
  * function to display the list data in datatable
  * the object for the viewing module must be set before the function call and all other member variables
  * @param integer $module_id
  * @param boolean $popup
  * @param string $primary_key
  * @see listdata.php, listdata_popup.php
  * The param $primary_key is used for a special purpose. When we use to view the related information we send 
  * the primary key value since if we see some related data for a module and if we do not send the primary key name
  * then the primary key will be used from the module instead of related modules
  * EX: if we want to see the related Contacts for a Prospect then we must send the primary key name 'idcontacts'
  * else it will take 'idpotential' as the primary key value. The query will not get the idpotentials since it will
  * run on Contacts and we do not want potential information on related tab.
  * @see listdata_related.php
  */
 public function display_data($module_id, $popup = false, $primary_key = '')
 {
     $do_crmfields = new CRMFields();
     $object = $this->get_ds_object();
     $module_info = $_SESSION["do_module"]->get_modules_with_full_info();
     $module_name = $module_info[$module_id]["name"];
     //Get the list query from the object
     $qry = $object->getSqlQuery();
     //security where condition
     $security_where = $this->get_ds_list_security();
     $group_by = '';
     if (property_exists($object, "list_query_group_by") === true && $object->list_query_group_by != '') {
         $group_by = " group by " . $object->list_query_group_by;
     }
     //echo $qry.$security_where.$group_by;exit;
     if ($object->get_list_tot_rows() == 0) {
         if (count($this->get_ds_additional_query_param()) > 0) {
             //echo '<br />1 '.$qry.$security_where.$this->get_ds_additional_where().$group_by ;
             $this->query($qry . $security_where . $this->get_ds_additional_where() . $group_by, $this->get_ds_additional_query_param());
         } elseif (strlen($this->get_ds_additional_where()) > 3) {
             //echo '<br />2 '.$qry.$security_where.$this->get_ds_additional_where().$group_by ;
             $this->query($qry . $security_where . $this->get_ds_additional_where() . $group_by);
         } else {
             //echo '<br />3 '.$qry.$security_where.$group_by ;
             $this->query($qry . $security_where . $group_by);
         }
         //Get the total number of records
         $iTotal = $this->getNumRows();
         $object->set_list_tot_rows($iTotal);
     } else {
         $iTotal = $object->get_list_tot_rows();
     }
     if ($this->get_ds_where_cond() != '') {
         if ($object->get_list_tot_rows() == 0) {
             if (strlen($this->get_ds_additional_where()) > 3) {
                 //echo '<br />11 '.$qry.$security_where.$this->get_ds_additional_where().$this->get_ds_where_cond().$group_by ;
                 $this->query($qry . $security_where . $this->get_ds_additional_where() . $this->get_ds_where_cond() . $group_by, $this->get_ds_search_params());
             } else {
                 //echo '<br />12 '.$qry.$security_where.$this->get_ds_where_cond().$group_by ;
                 $this->query($qry . $security_where . $this->get_ds_where_cond() . $group_by, $this->get_ds_search_params());
             }
             //Get the total number of records
             $iTotal = $this->getNumRows();
             $object->set_list_tot_rows($iTotal);
         } else {
             $iTotal = $object->get_list_tot_rows();
         }
     } else {
         if (strlen($this->get_ds_additional_where()) > 3) {
             //print_r($this->get_ds_search_params());
             //echo '<br />13 '.$qry.$security_where.$this->get_ds_additional_where().$group_by;
             $this->query($qry . $security_where . $this->get_ds_additional_where() . $group_by, $this->get_ds_search_params());
         } else {
             //echo '<br />14 '.$qry.$security_where.$group_by;
             $this->query($qry . $security_where . $group_by);
         }
         //Get the total number of records
         $iTotal = $this->getNumRows();
         $object->set_list_tot_rows($iTotal);
     }
     // Get the query limit and then add to the query
     $limit = '';
     $sql_start = $this->get_ds_sql_start();
     $sql_max = $this->get_ds_sql_max();
     if ($sql_start != '' && $sql_max != -1) {
         $limit = " LIMIT " . $sql_start . ", " . $sql_max;
     }
     // Get order by and then add to the query
     if ($this->get_ds_order_by() != '') {
         $order_by = " " . $this->get_ds_order_by();
     } else {
         if ($object->get_default_order_by() != "") {
             $order_by = " order by " . $object->get_default_order_by();
         }
     }
     // Get the where condition for the filter
     $where = '';
     if (strlen($this->get_ds_additional_where()) > 3) {
         $where .= $this->get_ds_additional_where();
     }
     if ($this->get_ds_where_cond() != '') {
         $where .= $this->get_ds_where_cond();
     }
     //The following part is ugly and we need something on Radria Core to use SELECT FOUND_ROWS()
     if ($this->get_ds_where_cond() != '') {
         if (count($this->get_ds_search_params()) > 0) {
             $this->query($qry . $security_where . $where . $group_by, $this->get_ds_search_params());
         } else {
             $this->query($qry . $security_where . $where . $group_by);
         }
         $iFilteredTotal = $this->getNumRows();
     } else {
         $iFilteredTotal = $iTotal;
     }
     //And finally execute the query
     $qry = $qry . $security_where . $where . $group_by . $order_by . $limit;
     if (count($this->get_ds_search_params()) > 0) {
         $this->query($qry, $this->get_ds_search_params());
     } else {
         $this->query($qry);
     }
     $output = array("sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => array());
     $edit = false;
     $delete = false;
     $detail = false;
     if ($this->get_ds_show_edit_link() === true && $popup === false && $_SESSION["do_crm_action_permission"]->action_permitted('edit', $module_id) === true) {
         $edit = true;
     }
     if ($this->get_ds_show_delete_link() === true && $popup === false && $_SESSION["do_crm_action_permission"]->action_permitted('delete', $module_id) === true) {
         $delete = true;
     }
     if ($this->get_ds_show_detail_link() === true && $popup === false && $_SESSION["do_crm_action_permission"]->action_permitted('view', $module_id) === true) {
         $detail = true;
     }
     if ($this->getNumRows() > 0) {
         $fields_info = $this->get_ds_fields_info();
         if ($primary_key == '') {
             $pkey = $object->primary_key;
         } else {
             $pkey = $primary_key;
         }
         while ($this->next()) {
             $row = array();
             if ($this->get_ds_show_record_selector() === true) {
                 if ($popup === true) {
                     $retrun_fields = $object->popup_selection_return_field;
                     $retrun_field_list = explode(",", $retrun_fields);
                     $retrun_field = '';
                     $cnt_return_fields = 0;
                     foreach ($retrun_field_list as $retrun_fields) {
                         if ($cnt_return_fields > 0) {
                             $retrun_field .= ' ';
                         }
                         $retrun_field .= $this->{$retrun_fields};
                         $cnt_return_fields++;
                     }
                     //$retrun_field
                     if (isset($_GET["special_field"]) && $_GET["special_field"] == 'yes') {
                         $special_field = $_GET["special_field"];
                         $special_field_name = $_GET["special_field_name"];
                         $chk_input = '<input type="checkbox" data-dismiss="modal" id="chk_popup' . $this->{$pkey} . '" onclick="return return_popup_selected_special(\'chk_popup' . $this->{$pkey} . '\');" value="' . $this->{$pkey} . '::' . $retrun_field . '">';
                     } elseif ($_REQUEST["line_item"] == 'yes') {
                         $chk_input = '<input type="checkbox" data-dismiss="modal" id="chk_popup' . $this->{$pkey} . '" onclick="return return_popup_line_item(\'chk_popup' . $this->{$pkey} . '\',\'' . $module_name . '\',\'' . $_REQUEST["line_level"] . '\');" value="' . $this->{$pkey} . '">';
                     } elseif (isset($_REQUEST["copy_org_address"]) && $_REQUEST["copy_org_address"] == 'yes') {
                         $chk_input = '<input type="checkbox" data-dismiss="modal" id="chk_popup' . $this->{$pkey} . '" onclick="return return_popup_copy_org_addr(\'chk_popup' . $this->{$pkey} . '\',\'' . $_REQUEST["target_module"] . '\');" value="' . $this->{$pkey} . '::' . $retrun_field . '">';
                     } elseif (isset($_REQUEST['copy_cnt_address']) && $_REQUEST['copy_cnt_address'] == 'yes') {
                         $chk_input = '<input type="checkbox" data-dismiss="modal" id="chk_popup' . $this->{$pkey} . '" onclick="return copy_cnt_address(\'chk_popup' . $this->{$pkey} . '\',\'' . $_REQUEST["target_module"] . '\');" value="' . $this->{$pkey} . '::' . $retrun_field . '">';
                     } else {
                         $chk_input = '<input type="checkbox" data-dismiss="modal" id="chk_popup' . $this->{$pkey} . '" onclick="return return_popup_selected(\'chk_popup' . $this->{$pkey} . '\');" value="' . $this->{$pkey} . '::' . $retrun_field . '">';
                     }
                 } else {
                     if ($module_id == 7 && $this->{$pkey} == 1) {
                         $chk_input = '<input type="hidden" name="chk[]" value="' . $this->{$pkey} . '">';
                     } else {
                         $chk_input = '<input type="checkbox" class="sel_record" name="chk[]" value="' . $this->{$pkey} . '">';
                     }
                 }
                 $row[] = $chk_input;
             } else {
                 $chk_input = '<input type="hidden" name="chk[]" value="' . $this->{$pkey} . '">';
                 $row[] = $chk_input;
             }
             foreach ($fields_info as $fields => $info) {
                 $fieldobject = 'FieldType' . $info["field_type"];
                 $row[] = $do_crmfields->display_field_value($this->{$fields}, $info["field_type"], $fieldobject, $this, $module_id);
             }
             $action_links = '';
             if ($detail === true) {
                 if ($action_links != '') {
                     $action_links .= '&nbsp;|&nbsp;';
                 }
                 $action_links .= '<a href="/modules/' . $module_name . '/detail?sqrecord=' . $this->{$pkey} . '">' . _('detail') . '</a>';
             }
             if ($edit === true) {
                 if ($action_links != '') {
                     $action_links .= '&nbsp;|&nbsp;';
                 }
                 $action_links .= '<a href="/modules/' . $module_name . '/edit?sqrecord=' . $this->{$pkey} . '">' . _('edit') . '</a> ';
             }
             if ($delete === true) {
                 if ($module_id == 7) {
                     if ($this->{$pkey} != 1) {
                         // admin user delete is not allowed
                         if ($action_links != '') {
                             $action_links .= '&nbsp;|&nbsp;';
                         }
                         $action_links .= '<a class="delete_entity_user" id="' . $this->{$pkey} . '" href="#">' . _('delete') . '</a>';
                     }
                 } else {
                     if ($action_links != '') {
                         $action_links .= '&nbsp;|&nbsp;';
                     }
                     $action_links .= '<a class="delete_entity" id="' . $this->{$pkey} . '" href="#">' . _('delete') . '</a>';
                 }
             }
             if ($action_links != '') {
                 $row[] = $action_links;
             }
             if ($action_links == '') {
                 $row[] = '';
             }
             $output["aaData"][] = $row;
         }
     }
     echo json_encode($output);
 }
Example #16
0
File: list.php Project: sQcrm/sqcrm
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* List view data 
* @author Abhik Chakraborty
*/
$list_object = new cpanel_invoice\Invoice();
$fields = $list_object->list_view_fields;
$do_crm_fields = new \CRMFields();
$fields_info = $do_crm_fields->get_specific_fields_information($fields, 15, true);
$module_namespace = 'cpanel_invoice';
if (isset($_GET['ajaxreq']) && $_GET['ajaxreq'] == true) {
    require_once 'view/listview_entry.php';
} else {
    require_once 'view/listview.php';
}
Example #17
0
 /**
  * Event Function to update user information
  * @param object $evctl
  */
 public function eventEditRecord(EventControler $evctl)
 {
     $permission = $_SESSION["do_user"]->is_admin == 1 ? true : false;
     $iduser = (int) $evctl->sqrecord;
     if ($iduser > 0 && true === $permission) {
         $this->getId($iduser);
         $do_crm_fields = new CRMFields();
         $crm_fields = $do_crm_fields->get_field_information_by_module_as_array((int) $evctl->idmodule);
         $data_array = array();
         foreach ($crm_fields as $crm_fields) {
             if ($crm_fields["field_type"] == 11) {
                 continue;
             }
             $field_name = $crm_fields["field_name"];
             $field_value = $do_crm_fields->convert_field_value_onsave($crm_fields, $evctl, 'edit');
             if (is_array($field_value) && count($field_value) > 0) {
                 if ($field_value["field_type"] == 12) {
                     $value = $field_value["name"];
                     $avatar_array[] = $field_value;
                 }
             } else {
                 $value = $field_value;
             }
             $data_array[$field_name] = $value;
         }
         $this->update(array($this->primary_key => $iduser), $this->getTable(), $data_array);
         if (is_array($avatar_array) && count($avatar_array) > 0) {
             foreach ($avatar_array as $avatar) {
                 if (is_array($avatar) && array_key_exists('name', $avatar)) {
                     $do_files_and_attachment = new CRMFilesAndAttachments();
                     $do_files_and_attachment->addNew();
                     $do_files_and_attachment->file_name = $avatar["name"];
                     $do_files_and_attachment->file_mime = $avatar["mime"];
                     $do_files_and_attachment->file_size = $avatar["file_size"];
                     $do_files_and_attachment->file_extension = $avatar["extension"];
                     $do_files_and_attachment->idmodule = 7;
                     $do_files_and_attachment->id_referrer = $iduser;
                     $do_files_and_attachment->iduser = 1;
                     $do_files_and_attachment->date_modified = date("Y-m-d H:i:s");
                     $do_files_and_attachment->add();
                 }
             }
         }
         // Record the history
         $do_data_history = new DataHistory();
         $do_data_history->add_history($iduser, 7, 'edit');
         $do_data_history->add_history_value_changes($iduser, 7, $this, $evctl);
         $_SESSION["do_crm_messages"]->set_message('success', _('Data updated successfully !'));
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('You do not have permission to add record !'));
         $next_page = NavigationControl::getNavigationLink("User", "list");
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     }
 }
Example #18
0
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* User add 
* @author Abhik Chakraborty
*/
$do_crmfields = new CRMFields();
$do_block = new Block();
$do_block->get_block_by_module($module_id);
?>

<div class="container-fluid">
	<div class="row-fluid">
		<?php 
include_once "modules/Settings/settings_leftmenu.php";
?>
			<div class="span9" style="margin-left:3px;">
				<div class="row-fluid">
					<div class="datadisplay-outer">
						<?php 
$e_add_entity = new Event($module . "->eventAddRecord");
$e_add_entity->addParam("idmodule", $module_id);
$e_add_entity->addParam("error_page", NavigationControl::getNavigationLink($module, "add"));
echo '<form class="form-horizontal" id="' . $module . '__addRecord" name="' . $module . '__addRecord" action="/eventcontroler.php" method="post" enctype="multipart/form-data">';
echo $e_add_entity->getFormEvent();
?>
						<div class="left_large">
							<a href="<?php 
echo NavigationControl::getNavigationLink($module, "users");
?>
Example #19
0
    $msg = _('Please select atleast one record to perform this operation.');
}
if ($allow_transfer === true) {
    $do_user = new User();
    $do_user->get_all_users();
    $group_transfer = false;
    $do_group = new Group();
    $do_group->get_all_groups();
    //if there is no group then there is no group to trasfer data
    if ($do_group->getNumRows() > 0) {
        $group_transfer = true;
    }
    if (true === $hide_group) {
        $group_transfer = false;
    }
    $do_fields = new CRMFields();
    $do_fields->query("select `idfields` from `fields` where `field_name` = 'assigned_to' AND `idmodule` = ?", array($module_id));
    $fieldid = 0;
    if ($do_fields->getNumRows() > 0) {
        $do_fields->next();
        $fieldid = $do_fields->idfields;
    }
    $e_change = new Event("CRMEntity->eventChangeAssignedToEntity");
    $e_change->addParam("ids", $ids);
    $e_change->addParam("module", $module);
    $e_change->addParam("module_id", $module_id);
    $e_change->addParam("fieldid", $fieldid);
    $e_change->addParam("next_page", NavigationControl::getNavigationLink($obj, $return_page));
    if ($group_transfer === true) {
        $e_change->addParam("group_transfer_opt", "yes");
    } else {
Example #20
0
?>
 - <?php 
echo _('Total : ') . $do_report->getNumRows() . ' ' . _('record(s)');
?>
				</div>
				<table cellpadding="0" cellspacing="0" border="0" class="datadisplay" id="sqcrmlist">
				<?php 
$fields_info = $do_report->get_report_fields();
$report_modules = $do_report->get_report_modules();
echo '<thead><tr>';
foreach ($fields_info as $key => $info) {
    echo '<th width="10%">' . $info["field_label"] . '</th>';
}
echo '</tr></thead>';
if ($do_report->getNumRows() > 0) {
    $do_crmfields = new CRMFields();
    while ($do_report->next()) {
        echo '<tr>';
        foreach ($fields_info as $fields => $info) {
            $fieldobject = 'FieldType' . $info["field_type"];
            $val = '';
            $field_name = '';
            if ($info["idmodule"] == $report_modules["primary"]["idmodule"]) {
                if ($info["field_type"] == 131) {
                    if ($info["field_name"] == 'idorganization') {
                        $val = $fieldobject::display_value($do_report->org_name, $do_report->org_name, false);
                    } elseif ($info["field_name"] == 'member_of') {
                        $val = $fieldobject::display_value($do_report->organization_member_of, $do_report->organization_member_of, false);
                    }
                } elseif ($info["field_type"] == 130) {
                    $val = $fieldobject::display_value($do_report->contact_report_to, $do_report->contact_report_to, false);
Example #21
0
 /**
  * Event function to update the organization data
  * @param object $evctl
  */
 public function eventEditRecord(EventControler $evctl)
 {
     $id_entity = (int) $evctl->sqrecord;
     if ($id_entity > 0 && true === $_SESSION["do_crm_action_permission"]->action_permitted('edit', 11, (int) $evctl->sqrecord)) {
         $obj = $this->getId($id_entity);
         $obj = (object) $obj;
         // convert the data array to Object
         $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, $id_entity, $obj);
         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", $id_entity);
             if ($evctl->return_page != '') {
                 $dis->addParam("return_page", $evctl->return_page);
             }
             $evctl->setDisplayNext($dis);
         } else {
             $do_crm_fields = new CRMFields();
             $crm_fields = $do_crm_fields->get_field_information_by_module_as_array((int) $evctl->idmodule);
             $table_entity = 'vendor';
             $table_entity_address = 'vendor_address';
             $table_entity_custom = 'vendor_custom_fld';
             $table_entity_to_grp = 'vendor_to_grp_rel';
             $entity_data_array = array();
             $custom_data_array = array();
             $addr_data_array = array();
             $assigned_to_as_group = false;
             foreach ($crm_fields as $crm_fields) {
                 $field_name = $crm_fields["field_name"];
                 $field_value = $do_crm_fields->convert_field_value_onsave($crm_fields, $evctl, 'edit');
                 if (is_array($field_value) && count($field_value) > 0) {
                     if ($field_value["field_type"] == 15) {
                         $field_name = 'iduser';
                         $value = $field_value["value"];
                         $assigned_to_as_group = $field_value["assigned_to_as_group"];
                         $group_id = $field_value["group_id"];
                     } elseif ($field_value["field_type"] == 12) {
                         $value = $field_value["name"];
                         $avatar_array[] = $field_value;
                     }
                 } else {
                     $value = $field_value;
                 }
                 if ($crm_fields["table_name"] == $table_entity && $crm_fields["idblock"] > 0) {
                     $entity_data_array[$field_name] = $value;
                 }
                 if ($crm_fields["table_name"] == $table_entity_address && $crm_fields["idblock"] > 0) {
                     $addr_data_array[$field_name] = $value;
                 }
                 if ($crm_fields["table_name"] == $table_entity_custom && $crm_fields["idblock"] > 0) {
                     $custom_data_array[$field_name] = $value;
                 }
             }
             $this->update(array($this->primary_key => $id_entity), $table_entity, $entity_data_array);
             //updating the last_modified,last_modified_by
             $q_upd = "\n\t\t\t\tupdate `" . $this->getTable() . "` set \n\t\t\t\t`last_modified` = ? ,\n\t\t\t\t`last_modified_by` = ? \n\t\t\t\twhere `" . $this->primary_key . "` = ?";
             $this->query($q_upd, array(date("Y-m-d H:i:s"), $_SESSION["do_user"]->iduser, $id_entity));
             if (count($custom_data_array) > 0) {
                 $this->update(array($this->primary_key => $id_entity), $table_entity_custom, $custom_data_array);
             }
             if (count($addr_data_array) > 0) {
                 $this->update(array($this->primary_key => $id_entity), $table_entity_address, $addr_data_array);
             }
             if ($assigned_to_as_group === false) {
                 $qry_grp_rel = "DELETE from `{$table_entity_to_grp}` where idvendor = ? LIMIT 1";
                 $this->query($qry_grp_rel, array($id_entity));
             } else {
                 $qry_grp_rel = "select * from `{$table_entity_to_grp}` where idvendor = ?";
                 $this->query($qry_grp_rel, array($id_entity));
                 if ($this->getNumRows() > 0) {
                     $this->next();
                     $id_grp_rel = $this->idvendor_to_grp_rel;
                     $q_upd = "\n\t\t\t\t\t\tupdate `{$table_entity_to_grp}` set \n\t\t\t\t\t\t`idgroup` = ?\n\t\t\t\t\t\twhere `idvendor_to_grp_rel` = ? LIMIT 1";
                     $this->query($q_upd, array($group_id, $id_grp_rel));
                 } else {
                     $this->insert($table_entity_to_grp, array("idvendor" => $id_entity, "idgroup" => $group_id));
                 }
             }
             // Record the history
             $do_data_history = new DataHistory();
             $do_data_history->add_history($id_entity, (int) $evctl->idmodule, 'edit');
             $do_data_history->add_history_value_changes($id_entity, (int) $evctl->idmodule, $obj, $evctl);
             //record the feed
             $feed_other_assigne = array();
             if ($assigned_to_as_group === true) {
                 $feed_other_assigne = array("related" => "group", "data" => array("key" => "newgroup", "val" => $group_id));
             }
             $do_feed_queue = new LiveFeedQueue();
             $do_feed_queue->add_feed_queue($id_entity, (int) $evctl->idmodule, $evctl->vendor_name, 'edit', $feed_other_assigne);
             // process after update plugin
             $do_process_plugins->process_action_plugins((int) $evctl->idmodule, $evctl, 4, $id_entity, $obj);
             $_SESSION["do_crm_messages"]->set_message('success', _('Data updated successfully !'));
             $next_page = NavigationControl::getNavigationLink($evctl->module, "detail");
             $dis = new Display($next_page);
             $dis->addParam("sqrecord", $id_entity);
             $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);
     }
 }
Example #22
0
 /**
  * function to get data history display text
  * @param object $obj
  * @param boolean $link
  * @param boolean $user_history
  * @return array $ret_array
  */
 public function get_data_history_display_text($obj, $link = false, $user_history = false)
 {
     $row1 = '<strong>' . $obj->firstname . ' ' . $obj->lastname . '</strong> ' . _('on ') . '<i>' . i18nDate::i18n_long_time(TimeZoneUtil::convert_to_user_timezone($obj->date_modified, true)) . '</i>';
     switch ($obj->action) {
         case 'add':
             if ($user_history === true) {
                 $row2 = _('Added') . ' ' . CommonUtils::get_module_name_as_text($obj->idmodule);
             } else {
                 $row2 = _('Added the record');
             }
             break;
         case 'delete':
             if ($user_history === true) {
                 $row2 = _('Deleted') . ' ' . CommonUtils::get_module_name_as_text($obj->idmodule);
             } else {
                 $row2 = _('Deleted the record');
             }
             break;
         case 'edit':
             if ($user_history === true) {
                 $row2 = _('Updated') . ' ' . CommonUtils::get_module_name_as_text($obj->idmodule);
             } else {
                 $row2 = _('Updated the record');
             }
             break;
         case 'value_changes':
             $do_crm_fields = new CRMFields();
             $do_crm_fields->getId($obj->idfields);
             if ($do_crm_fields->getNumRows() > 0) {
                 $field_label = $do_crm_fields->field_label;
                 $old_value = $obj->old_value;
                 $new_value = $obj->new_value;
                 if ($do_crm_fields->field_type == 9) {
                     $old_value = FieldType9::display_value($old_value);
                     $new_value = FieldType9::display_value($new_value);
                 }
                 if ($user_history === true) {
                     $row2 = _('Changed value in') . ' ' . CommonUtils::get_module_name_as_text($obj->idmodule) . ' , ' . $field_label . ' :: ' . $old_value . ' >>> ' . $new_value;
                 } else {
                     $row2 = _('Changed') . ' ' . $field_label . ' :: ' . $old_value . ' >>> ' . $new_value;
                 }
             }
             $do_crm_fields->free();
             break;
     }
     if ($obj->user_avatar != '') {
         $avatar_path = $GLOBALS['AVATAR_DISPLAY_PATH'];
         $thumb = $avatar_path . '/ths_' . $obj->user_avatar . '.' . $obj->file_extension;
     }
     if ($link === true) {
         $detail_url = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$obj->idmodule]["name"], "detail", $obj->id_referrer);
         $row2 .= '&nbsp;<a href="' . $GLOBALS['SITE_URL'] . $detail_url . '">' . $GLOBALS['SITE_URL'] . $detail_url . '</a>';
     }
     $ret_array = array("avatar" => $thumb, "row1" => $row1, "row2" => $row2);
     return $ret_array;
 }
Example #23
0
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Pick List/ Multi select combo values manage page
* @author Abhik Chakraborty
*/
$do_crm_fields = new CRMFields();
$do_combo_values = new ComboValues();
$non_editable_combo_fields = $do_combo_values->get_non_editable_combo_fields();
// modules which does not have the custom fields or any fields
$ignore_modules = array(1, 8, 9);
if (isset($_GET["cmid"]) && $_GET["cmid"] != '') {
    $cf_module = (int) $_GET["cmid"];
} else {
    $cf_module = 3;
}
$modules_info = $_SESSION["do_module"]->get_modules_with_full_info();
$do_crm_fields->get_pick_multiselect_fields($cf_module);
$data_array = array();
if ($do_crm_fields->getNumRows() > 0) {
    while ($do_crm_fields->next()) {
        $combo_data = array();
        if (in_array($do_crm_fields->idfields, $non_editable_combo_fields)) {
            continue;
        }
        $do_combo_values->get_combo_values($do_crm_fields->idfields);
        if ($do_combo_values->getNumRows() > 0) {
            $combo_data = array();
            while ($do_combo_values->next()) {
                $combo_data[] = $do_combo_values->combo_value;
Example #24
0
File: edit.php Project: sQcrm/sqcrm
            $do_edit = false;
        }
        if ($module_obj->is_editable == 0) {
            $do_edit = false;
        }
    } else {
        $do_edit = false;
    }
} else {
    $do_edit = false;
}
if ($do_edit === false) {
    echo '<div class="alert alert-error alert-block" style="height:100px;margin-top:100px;margin-left:200px;margin-right:200px;">';
    echo '<h4>';
    echo _('Access Denied ! ');
    echo '</h4>';
    echo _('You are not authorized to perform this operation.');
    echo '</div>';
} else {
    $do_crmfields = new CRMFields();
    $do_custom_view_fields = new CustomViewFields();
    $do_custom_view_filter = new CustomViewFilter();
    $cv_fields = $do_crmfields->get_fieldinfo_grouped_by_block($module_obj->idmodule, true);
    $date_filters = $do_crmfields->get_date_fields($module_obj->idmodule, true);
    $date_filter_options = ViewFilterUtils::get_date_filter_otions();
    $advanced_filter_options = ViewFilterUtils::get_advanced_filter_options();
    $saved_fields = $do_custom_view_fields->get_custom_view_fields($sqcrm_record_id);
    $saved_date_filter = $do_custom_view_filter->get_date_filter_information($sqcrm_record_id);
    $saved_advanced_filter = $do_custom_view_filter->get_saved_advanced_filter_information($sqcrm_record_id);
    require_once 'view/customview_edit_view.php';
}