示例#1
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);
     }
 }
示例#2
0
文件: listview.php 项目: sQcrm/sqcrm
						} ?>
						
						<!-- Change Bulk Calendar Status -->
						<?php
						if ($module_id == 2) {
						?>
						<a href="#" class="btn btn-primary btn-xs" id="change_event_status">
						<span class="glyphicon glyphicon-calendar" aria-hidden="true"></span> <?php echo _('change event status');?>
						</a>
						<?php
						}
						?>
						<!-- Show the list view action plugin buttons-->
						<?php
						// process the detail view right block active modules
						$do_process_list_plugins = new CRMPluginProcessor();
						$do_process_list_plugins->process_listview_action_plugin($module_id,$active_plugins);
						?>
					</div>
					<div class="col-md-4">	
						<form class="form-inline">
						<?php
						if (true === $custom_view_allowed) { // defined on modules/{module_name}/list.php
							if ($_SESSION["do_crm_action_permission"]->action_permitted('view',17)) {
								if (is_array($custom_view_data) && count($custom_view_data) > 0) {
									$is_editable_selected_custom_view = false ;
									$is_deleteable_selected_custom_view = false ;
								?>
								<div class="form-group">
								<select name="customview_filter" id="customview_filter" class="form-control input-sm">
								<?php
示例#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);
     }
 }
// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* detail view right block
* @author Abhik Chakraborty
*/
?>
<div class="span5" style="margin-left:10px;">
	<div class="row-fluid">
		<?php 
if ($module_id == 2) {
    // calendar
    require "detail_view_calendar_rightblock.php";
} else {
    if ($module_id == 3 && $converted_lead === true) {
        require "detail_view_rightblock_converted_leads.php";
    } else {
        require "detail_view_rightblock_actions.php";
    }
}
if ($module_id == 3 && $converted_lead === true) {
    // do nothing
} else {
    //require("detail_view_notes.php");
}
// process the detail view right block active modules
$do_process_plugins = new CRMPluginProcessor();
$do_process_plugins->process_detail_view_plugin($module_id, $sqcrm_record_id, $active_plugins);
?>
	</div>
</div>
示例#5
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';
     }
 }