function handleMassUpdate() { require_once 'include/formbase.php'; global $current_user, $db; if (!is_array($this->sugarbean) && $this->sugarbean->bean_implements('ACL') && !ACLController::checkAccess($this->sugarbean->module_dir, 'edit', true)) { } foreach ($_POST as $post => $value) { if (empty($value)) { unset($_POST[$post]); } } if (!empty($_REQUEST['uid'])) { $_POST['mass'] = explode(',', $_REQUEST['uid']); } elseif (isset($_REQUEST['entire'])) { if (isset($_SESSION['export_where']) && !empty($_SESSION['export_where'])) { // bug 4679 $where = $_SESSION['export_where']; } else { $where = ''; } if (empty($order_by)) { $order_by = ''; } $query = $this->sugarbean->create_export_query($order_by, $where); $result = $db->query($query, true); $new_arr = array(); while ($val = $db->fetchByAssoc($result, -1, false)) { array_push($new_arr, $val['id']); } $_POST['mass'] = $new_arr; } if (isset($_POST['mass']) && is_array($_POST['mass'])) { foreach ($_POST['mass'] as $id) { if (isset($_POST['Delete'])) { $this->sugarbean->retrieve($id); if ($this->sugarbean->ACLAccess('Delete')) { $this->sugarbean->mark_deleted($id); //Peter Peshev - Delete SupplyLines - 06.02.2007 if ($this->sugarbean->object_name == 'Supply') { $SupplyLine = new SupplyLine(); $SupplyLine->mark_deletedBySupplyid($id); } } } else { if ($this->sugarbean->object_name == 'Contact' && isset($_POST['Sync'])) { // special for contacts module if ($_POST['Sync'] == 'true') { $this->sugarbean->retrieve($id); if ($this->sugarbean->ACLAccess('EditView')) { if ($this->sugarbean->object_name == 'Contact') { $this->sugarbean->contacts_users_id = $current_user->id; $this->sugarbean->save(false); } } } elseif ($_POST['Sync'] == 'false') { $this->sugarbean->retrieve($id); if ($this->sugarbean->ACLAccess('EditView')) { if ($this->sugarbean->object_name == 'Contact') { if (!isset($this->sugarbean->users)) { $this->sugarbean->load_relationship('user_sync'); } $this->sugarbean->contacts_users_id = null; $this->sugarbean->user_sync->delete($this->sugarbean->id, $current_user->id); } } } } $this->sugarbean->retrieve($id); if ($this->sugarbean->ACLAccess('EditView')) { $_POST['record'] = $id; $_GET['record'] = $id; $_REQUEST['record'] = $id; $newbean = $this->sugarbean; populateFromPost('', $newbean); $newbean->save_from_post = false; $check_notify = FALSE; if (isset($this->sugarbean->assigned_user_id)) { $old_assigned_user_id = $this->sugarbean->assigned_user_id; if (!empty($_POST['assigned_user_id']) && $old_assigned_user_id != $_POST['assigned_user_id'] && $_POST['assigned_user_id'] != $current_user->id) { $check_notify = TRUE; } } $newbean->save($check_notify); } } } } }
* You must: * a) Document any modifications you make to this code including the nature of * the change, the authors of the change, and the date of the change. * b) Make the source code for any extensions you deploy available via an * Electronic Distribution Mechanism such as FTP or HTTP download. * c) Notify the licensor of the availability of source code to your extensions * and include instructions on how to acquire the source code and updates. * d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use, * reproduce, perform, modify, sublicense, and distribute your extensions. * * The Original Code is: C3CRM Team * http://www.c3crm.com * 2006-5-19 * * The Initial Developer of the Original Code is C3CRM Team. * Portions created by C3CRM are Copyright (C) 2005 C3CRM * All Rights Reserved. * Contributors: Goodwill Consulting http://www.goodwill.co.id ********************************************************************************/ require_once 'modules/Supplies/Supply.php'; require_once 'modules/SupplyLines/SupplyLine.php'; global $mod_strings; require_once 'log4php/LoggerManager.php'; $focus = new Supply(); $focus_spp_line = new SupplyLine(); if (!isset($_REQUEST['record'])) { sugar_die($mod_strings['ERR_DELETE_RECORD']); } $focus_spp_line->mark_deletedBySupplyid($_REQUEST['record']); $focus->mark_deleted($_REQUEST['record']); header("Location: index.php?module=" . $_REQUEST['return_module'] . "&action=" . $_REQUEST['return_action'] . "&record=" . $_REQUEST['return_id']);
function handleSave($prefix, $redirect = true, $useRequired = false) { require_once 'modules/Supplies/Supply.php'; require_once 'modules/SupplyLines/SupplyLine.php'; require_once 'log4php/LoggerManager.php'; require_once 'include/formbase.php'; require_once 'include/TimeDate.php'; $timedate = new TimeDate(); $focus = new Supply(); if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } $focus = populateFromPost($prefix, $focus); if (!ACLController::checkAccess($focus->module_dir, 'edit', $focus->isOwner($current_user->id))) { ACLController::displayNoAccess(true); } $return_id = $focus->save(); $supplyLine1 = new SupplyLine(); $supplyLine1->mark_deletedBySupplyid($return_id); $count = count($_POST); $keys = array_keys($_POST); $sum = 0; for ($i = 0; $i < $count; $i++) { //echo $keys[$i]."<br>"; if (substr_count($keys[$i], "materialname_") > 0) { $index = substr($keys[$i], strpos($keys[$i], "_") + 1); $materialid = $_POST["materialid_" . $index]; $paperid = $_POST["paperid_" . $index]; if (!isset($materialid) && empty($materialid) && !isset($paperid) && empty($paperid)) { continue; } $materialname = $_POST["materialname_" . $index]; $number = $_POST["number_" . $index]; $measure = $_POST["measure_" . $index]; $unit = $_POST["unit_" . $index]; $singlep = $_POST["singlep_" . $index]; $price = $_POST["price_" . $index]; $supplynum = $_POST["supplynum"]; $status = $_POST["status"]; $delivery_date = $_POST["delivery_date"]; $delivered_date = $_POST["delivered_date"]; $supplyLine = new SupplyLine(); $supplyLine->number = $number; $supplyLine->materialid = $materialid; $supplyLine->paperid = $paperid; $supplyLine->materialname = $materialname; $supplyLine->measure = $measure; $supplyLine->unit = $unit; $supplyLine->singlep = $singlep; $supplyLine->price = $price; $supplyLine->supplynum = $supplynum; $supplyLine->supplyid = $return_id; $supplyLine->status = $status; $supplyLine->delivery_date = $delivery_date; $supplyLine->delivered_date = $delivered_date; $supplyLine->save(); } } $count = $_POST["product_count"]; // $GLOBLES['log']->debug("Saved record with id of ".$return_id); if ($redirect) { $this->handleRedirect($return_id); } else { return $focus; } }