function component_update($id, $close = false)
 {
     $product_estimate = new ProductEstimate();
     $components_estimate = new ComponentEstimate();
     $product = new Products();
     $query = ' SELECT id FROM ' . $components_estimate->table_name . ' WHERE component_id="' . $id . '" AND deleted=0 ';
     $result = $this->db->query($query, true, "");
     if ($result != false) {
         while ($data = $this->db->fetchByAssoc($result)) {
             $components_estimate->mark_deleted($data['id']);
         }
     }
     $query = ' UPDATE ' . $product->table_name . ' SET status="draft" WHERE id="' . $this->parent_id . '" AND deleted=0 ';
     $this->db->query($query, true, "");
     $query = ' UPDATE ' . $product_estimate->table_name . ' SET status="outdated" WHERE id="' . $this->parent_id . '" AND deleted=0 ';
     $this->db->query($query, true, "");
 }
Пример #2
0
 function estimate_update($id, $close = false)
 {
     $estimate_estimate = new EstimateCalc();
     $components_estimate = new ComponentEstimate();
     $component = new EstimateComponents();
     if (close == true) {
         $query = ' UPDATE ' . $estimate_estimate->table_name . ' SET status="closed" WHERE estimate_id="' . $id . '" AND deleted=0 ';
         $this->db->query($query, true, "");
     } else {
         $query = ' SELECT id FROM ' . $estimate_estimate->table_name . ' WHERE estimate_id="' . $id . '" AND deleted=0 ';
         $result = $this->db->query($query, true, "");
         if ($result != false) {
             while ($data = $this->db->fetchByAssoc($result)) {
                 $estimate_estimate->mark_deleted($data['id']);
             }
         }
     }
     $query = ' SELECT id FROM ' . $component->table_name . ' WHERE parent_id="' . $id . '" AND deleted=0 ';
     $result = $this->db->query($query, true, "");
     if ($result != false) {
         if (close == true) {
             $query = ' UPDATE ' . $component->table_name . ' SET status="closed" WHERE parent_id="' . $id . '" AND deleted=0 ';
             $this->db->query($query, true, "");
         }
         while ($data = $this->db->fetchByAssoc($result)) {
             if (close == true) {
                 $query = ' UPDATE ' . $components_estimate->table_name . ' SET status="closed" WHERE component_id="' . $data['id'] . '" AND deleted=0 ';
                 $this->db->query($query, true, "");
             } else {
                 $component->mark_deleted($data['id']);
                 $query = ' SELECT id FROM ' . $components_estimate->table_name . ' WHERE component_id="' . $data['id'] . '" AND deleted=0 ';
                 $result_components_estimate = $this->db->query($query, true, "");
                 if ($result_components_estimate != false) {
                     while ($data = $this->db->fetchByAssoc($result)) {
                         $components_estimate->mark_deleted($data['id']);
                     }
                 }
             }
         }
     }
 }
Пример #3
0
 * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 */
require_once 'modules/ComponentEstimate/ComponentEstimate.php';
$sugarbean = new ComponentEstimate();
// perform the delete if given a record to delete
if (empty($_REQUEST['record'])) {
    $GLOBALS['log']->info('delete called without a record id specified');
} else {
    $record = $_REQUEST['record'];
    $sugarbean->retrieve($record);
    if (!$sugarbean->ACLAccess('Delete')) {
        ACLController::displayNoAccess(true);
        sugar_cleanup(true);
    }
    $GLOBALS['log']->info("deleting record: {$record}");
    $sugarbean->delete_estimate($record);
    $sugarbean->mark_deleted($record);
}
// handle the return location variables
$return_module = empty($_REQUEST['return_module']) ? 'ComponentEstimate' : $_REQUEST['return_module'];
$return_action = empty($_REQUEST['return_action']) ? 'index' : $_REQUEST['return_action'];
$return_id = empty($_REQUEST['return_id']) ? '' : $_REQUEST['return_id'];
$return_location = "index.php?module={$return_module}&action={$return_action}";
// append the return_id if given
if (!empty($return_id)) {
    $return_location .= "&record={$return_id}";
}
// now that the delete has been performed, return to given location
header("Location: {$return_location}");