function estimate_details($id, $details = 'details', $update_estimate = 'update_estimate')
 {
     global $current_language, $app_list_strings;
     $object = new ComponentEstimate();
     $mod_strings = return_module_language($current_language, $object->object_name);
     $object->retrieve($id);
     $xtpl = new XTemplate('modules/ComponentEstimate/EstimateDetails.html');
     $xtpl->assign('MOD', $mod_strings);
     if ($object->status == "uptodate") {
         /////////////  DETAILS  /////////////
         $prepress = $object->prepressEstimate($object->component_id);
         $press_rate[] = $object->press_rate_a_id;
         $press_rate[] = $object->press_rate_b_id;
         $pressestimate = $object->pressEstimate($object->component_id, $press_rate);
         $paperestimate = $object->paperEstimate($object->component_id, $object->paper_rate_id);
         $operations = $object->operationsEstimate($object->component_id, true);
         ///Press
         $xtpl->assign("press_price_lines", $pressestimate['layout_html']);
         ///
         ///Paper & Paperwaste
         $client_paper = $paperestimate['client_paper'];
         $xtpl->assign("paper_singleprice", $paperestimate['paper_singleprice']);
         $xtpl->assign("clean_quantity_qp", $paperestimate['clean_quantity_qp']);
         $xtpl->assign("paperwaste_qp", $paperestimate['paperwaste_qp']);
         $xtpl->assign("qp", $paperestimate['qp']);
         $xtpl->assign("sheets_qp", $paperestimate['sheets_qp']);
         $xtpl->assign("pages", $paperestimate['pages']);
         $xtpl->assign("paper_waste_rows", $paperestimate['paperestimate_html']);
         $xtpl->assign("paper_operation_waste_rows", $paperestimate['operations_html']);
         $xtpl->assign("client_paper", $app_list_strings['client_paper_options'][$client_paper]);
         ///
         ///Prepress
         $xtpl->assign("prepress_lines", $prepress['html']);
         ///
         ///Operations
         $xtpl->assign("operation_lines", $operations['html']);
         ///
         $xtpl->assign("details", $details);
         ////////////////////////////////////
     } else {
         $xtpl->assign("details", $update_estimate);
     }
     $xtpl->parse('details');
     $xtpl->out('details');
 }
 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']);
                     }
                 }
             }
         }
     }
 }
    function component_estimate_details()
    {
        global $current_language, $app_list_strings;
        $object = new ComponentEstimate();
        $mod_strings = return_module_language($current_language, $object->object_name);
        $html = '<br><table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabDetailView">
					  <tr> 
					    <td width="30%" style="text-align:left" class="tabDetailViewDL"><span sugar="slot1">' . $mod_strings["LBL_NAME"] . '</span sugar="slot"></td> 
					    <td width="10%" style="text-align:left" class="tabDetailViewDL"><span sugar="slot5">' . $mod_strings["LBL_PREPRESS_TOTAL"] . '</span sugar="slot"></td>
					    <td width="10%" style="text-align:left" class="tabDetailViewDL"><span sugar="slot7">' . $mod_strings["LBL_PRESS_TOTAL"] . '</span sugar="slot"></td>
					    <td width="10%" style="text-align:left" class="tabDetailViewDL"><span sugar="slot5">' . $mod_strings["LBL_PAPER_TOTAL"] . '</span sugar="slot"></td>
					    <td width="40%" style="text-align:left" class="tabDetailViewDL"><span sugar="slot7">' . $mod_strings["LBL_OPERATIONS_TOTAL"] . '</span sugar="slot"></td>
					  </tr></table>';
        echo $html;
        $query = 'SELECT id FROM componentestimate WHERE product_id="' . $this->product_id . '" AND deleted=0 ';
        $result = $this->db->query($query, true, "Error filling layout fields: ");
        $i = 0;
        while (($row = $this->db->fetchByAssoc($result)) != null) {
            $i = $i + 1;
            $details = "details_" . $i;
            $update_estimate = "update_estimate_" . $i;
            $object->retrieve($row['id']);
            $html = '<table  width="100%" border="0" cellspacing="0" cellpadding="0" class="tabDetailView"><tr>
					    <td align="left" width="30%" class="tabDetailViewDF"><span sugar="slot7b"><a href="index.php?module=ComponentEstimate&action=DetailView&record=' . $object->id . '">' . $object->name . '</a></span sugar="slot"></td> 
					    <td width="10%" class="tabDetailViewDF"><span sugar="slot5b">' . $object->total_prepress . '</span sugar="slot"></td>
					    <td width="10%" class="tabDetailViewDF"><span sugar="slot7b">' . $object->total_press . '</span sugar="slot"></td>
					    <td width="10%" class="tabDetailViewDF"><span sugar="slot5b">' . $object->total_paper . '</span sugar="slot"></td>
					    <td width="40%" class="tabDetailViewDF"><span sugar="slot7b">' . $object->total_operations . '</span sugar="slot"></td>
					  </tr> 
					</table>';
            echo $html;
            $object->estimate_details($object->id, $details, $update_estimate);
        }
    }
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 */
require_once 'XTemplate/xtpl.php';
require_once 'data/Tracker.php';
require_once 'modules/ComponentEstimate/ComponentEstimate.php';
require_once 'include/time.php';
require_once 'modules/ComponentEstimate/Forms.php';
require_once 'include/formbase.php';
global $timedate;
global $app_strings;
global $app_list_strings;
global $current_language;
global $current_user;
global $sugar_version, $sugar_config;
$focus = new ComponentEstimate();
if (!empty($_REQUEST['record'])) {
    $focus->retrieve($_REQUEST['record']);
}
if (!empty($_REQUEST['component_id']) && isset($_REQUEST['component_id']) && !is_null($_REQUEST['component_id'])) {
    $component_id = $_REQUEST['component_id'];
}
if (isset($focus->component_id) && !is_null($focus->component_id)) {
    $component_id = $focus->component_id;
}
$press_rate = array();
$press_rate[] = null;
$press_rate[] = null;
if (isset($_REQUEST['press_rate_a_id']) && !empty($_REQUEST['press_rate_a_id'])) {
    $press_rate[0] = $_REQUEST['press_rate_a_id'];
}
 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, "");
 }
 * License.
 *
 * All copies of the Covered Code must include on each user interface screen:
 *    (i) the "Powered by SugarCRM" logo and
 *    (ii) the SugarCRM copyright notice
 * in the same form as they appear in the distribution.  See full license for
 * requirements.
 *
 * The Original Code is: SugarCRM Open Source
 * The Initial Developer of the Original Code is SugarCRM, Inc.
 * 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