* Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 */
require_once 'XTemplate/xtpl.php';
require_once 'data/Tracker.php';
require_once 'modules/Estimates/Estimates.php';
require_once 'include/time.php';
require_once 'modules/Estimates/Forms.php';
global $timedate;
global $app_strings;
global $app_list_strings;
global $current_language;
global $current_user;
global $sugar_version, $sugar_config;
$focus = new Estimates();
if (!empty($_REQUEST['record'])) {
    $focus->retrieve($_REQUEST['record']);
}
echo "\n<p>\n";
echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . ": " . $focus->name, true);
echo "\n</p>\n";
global $theme;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
require_once $theme_path . 'layout_utils.php';
$GLOBALS['log']->info("Estimates detail view");
$xtpl = new XTemplate('modules/Estimates/ProductSelect.html');
$json = getJSONobj();
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array('id' => 'product_id', 'name' => 'product_name'));
$encoded_product_popup_request_data = $json->encode($popup_request_data);
Ejemplo n.º 2
0
require_once dirname(dirname(dirname(__FILE__))) . '/modules/Room.class.php';
require_once dirname(dirname(dirname(__FILE__))) . '/modules/Estimates.class.php';
require_once dirname(dirname(dirname(__FILE__))) . '/modules/Dynamo.class.php';
require_once dirname(dirname(dirname(__FILE__))) . '/modules/Tools.class.php';
$propertyId = isset($_GET['propertyId']) ? $_GET['propertyId'] : 0;
$estimatesId = isset($_GET['estimatesId']) ? $_GET['estimatesId'] : 0;
if ($propertyId != 0 && $estimatesId != 0) {
    $propertyObj = new Property();
    $propertyInfo = $propertyObj->getPropertyInfo($propertyId, false);
    $roomObj = new Room();
    $listRoomTemplates = $roomObj->getRoomTemplates(false);
    if (!$propertyInfo) {
        echo "No property found.";
        return;
    }
    $estimatesObj = new Estimates();
    $estimatesInfo = $estimatesObj->getEstimateDetails_estimates($estimatesId, false);
    $disable_room_addition = false;
    $reportObj = new Report();
    $reportId = $reportObj->getPreviousReportId($propertyId, false);
    if ($reportId) {
        $reportInfo = $reportObj->getReportDetails($reportId, false);
    }
    if (count($reportInfo['rooms']) > 0) {
        $disable_room_addition = true;
    }
    $estimate_room_items_units_obj = new Dynamo("estimate_room_items_units");
    $query = "SELECT estimate_room_items_units.*, work_category_estimates.item_name, work_category_estimates.unit_of_measure FROM estimate_room_items_units \n\tINNER JOIN work_category_estimates ON estimate_room_items_units.work_category_estimates_id = work_category_estimates.id \n\tWHERE estimate_room_items_units.estimate_id = " . $estimatesId;
    $estimate_room_items_units_array = $estimate_room_items_units_obj->customFetchQuery($query);
    if (count($estimate_room_items_units_array) > 0) {
        $arrayCount = array();
Ejemplo n.º 3
0
 */
require_once 'XTemplate/xtpl.php';
require_once 'data/Tracker.php';
require_once 'modules/Estimates/Estimates.php';
require_once 'modules/Products/Products.php';
require_once 'modules/ClientRequest/ClientRequest.php';
require_once 'modules/EstimateComponents/EstimateComponents.php';
require_once 'include/time.php';
require_once 'modules/Estimates/Forms.php';
global $timedate;
global $app_strings;
global $app_list_strings;
global $current_language;
global $current_user;
global $sugar_version, $sugar_config;
$focus = new Estimates();
if (!empty($_REQUEST['record'])) {
    $focus->retrieve($_REQUEST['record']);
}
echo "\n<p>\n";
echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . ": " . $focus->name, true);
echo "\n</p>\n";
global $theme;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
require_once $theme_path . 'layout_utils.php';
$GLOBALS['log']->info("Estimates detail view");
$xtpl = new XTemplate('modules/Estimates/EditView.html');
/// Users Popup
$json = getJSONobj();
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array('id' => 'assigned_user_id', 'user_name' => 'assigned_user_name'));
Ejemplo n.º 4
0
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/modules/Property.class.php';
require_once dirname(dirname(dirname(__FILE__))) . '/modules/Report.class.php';
require_once dirname(dirname(dirname(__FILE__))) . '/modules/Estimates.class.php';
require_once dirname(dirname(dirname(__FILE__))) . '/modules/Dynamo.class.php';
$propertyId = isset($_GET['propertyId']) ? $_GET['propertyId'] : 0;
$report_images = new Dynamo("report_images");
if ($propertyId != 0) {
    $propertyObj = new Property();
    $propertyInfo = $propertyObj->getPropertyInfo($propertyId, false);
    $estimates_obj = new Dynamo("estimates");
    $estimatesArray = $estimates_obj->getAll("WHERE property_id = " . $propertyId . " AND is_saved = 1");
    $estimatesArray = $estimatesArray[0];
    $reportObj = new Report();
    $estimatesObj = new Estimates();
    $usersObj = new Dynamo("users");
    $array_users = $usersObj->getAllWithId_default(false, "id");
    $subContractorsObj = new Dynamo("sub_contractors");
    $array_sub_contractors = $subContractorsObj->getAllWithId_default(false, "id");
    $companiesObj = new Dynamo("companies");
    $array_companies = $companiesObj->getAllWithId_default(false, "id");
    $dailyLogsObj = new Dynamo("daily_logs");
    /*$reportObj = new Report();
    	$reports = $reportObj->getReportsSummary($propertyId, false,$array_users,$array_sub_contractors,$array_companies);**/
    $reports = $reportObj->getReportsSummary($propertyId, false, $array_users, $array_sub_contractors, $array_companies);
    $estimates = $estimatesObj->getEstimatesSummary($propertyId, false, $array_users, $array_companies);
    $daily_logs = $dailyLogsObj->getAll("WHERE property_id = " . $propertyId . " ORDER BY timestamp DESC");
    $array_reports_estimates = array();
    for ($i = 0; $i < count($reports); $i++) {
        $reports[$i]['report'] = true;
Ejemplo n.º 5
0
<?php

$propertyId = isset($_POST['propertyId']) ? $_POST['propertyId'] : 0;
if ($propertyId != 0) {
    $propertyObj = new Property();
    $propertyInfo = $propertyObj->getPropertyInfo($propertyId, false);
    $roomObj = new Room();
    $listRoomTemplates = $roomObj->getRoomTemplates(false);
    if (!$propertyInfo) {
        echo "No property found.";
        return;
    }
    $estimatesObj = new Estimates();
    $estimatesId = $estimatesObj->getPreviousEstimatesId($propertyId, false);
    $estimateInfo = $estimatesObj->getEstimateDetails_estimates($estimatesId, false);
    $copy_from_report = false;
    if (count($estimateInfo['rooms']) <= 0) {
        $reportObj = new Report();
        $reportId = $reportObj->getPreviousReportId($propertyId, false);
        $reportInfo = $reportObj->getReportDetails($reportId, false);
        if (count($reportInfo['rooms']) > 0) {
            $estimateInfo = $reportInfo;
            $copy_from_report = true;
        }
    }
    if (count($estimateInfo['rooms']) > 0) {
        $estimates_obj = new Dynamo("estimates");
        $room_templates_obj = new Dynamo("room_templates");
        $estimate_rooms_obj = new Dynamo("estimate_rooms");
        $estimate_room_items_obj = new Dynamo("estimate_room_items");
        $estimate_room_items_units_obj = new Dynamo("estimate_room_items_units");
Ejemplo n.º 6
0
 function get_status($id = null)
 {
     if (!is_null($id)) {
         $esteimate = new Estimates();
         $esteimate->retrieve($id);
         $product = new Products();
         $product->retrieve($esteimate->product_id);
         if (!is_null($product->status)) {
             return $product->status;
         }
     }
     return 'new_estimate';
 }
Ejemplo n.º 7
0
 * 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/Estimates/Estimates.php';
$sugarbean = new Estimates();
// 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->estimate_update($sugarbean->id);
    $sugarbean->mark_deleted($record);
}
// handle the return location variables
Ejemplo n.º 8
0
$xtpl->assign('encoded_contact_popup_request_data', $encoded_contact_popup_request_data);
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array('id' => 'calculant_id', 'user_name' => 'calculant_name'));
$xtpl->assign('encoded_calculant_popup_request_data', $json->encode($popup_request_data));
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array('id' => 'contact_id', 'name' => 'contact_name'));
$encoded_contact_popup_request_data = $json->encode($popup_request_data);
$xtpl->assign('encoded_contact_popup_request_data', $encoded_contact_popup_request_data);
$popup_request_data = array('call_back_function' => 'set_return_product', 'form_name' => 'EditView', 'field_to_name_array' => array('id' => 'product_id', 'name' => 'product_name', 'account_id' => 'account_id', 'account_name' => 'account_name', 'contact_id' => 'contact_id', 'contact_name' => 'contact_name', 'number' => 'number'));
$encoded_contact_popup_request_data = $json->encode($popup_request_data);
$xtpl->assign('encoded_products_popup_request_data', $encoded_contact_popup_request_data);
///
/// Assign the template variables
///
$xtpl->assign('MOD', $mod_strings);
$xtpl->assign('APP', $app_strings);
if (isset($_REQUEST['estimate_id']) && !empty($_REQUEST['estimate_id'])) {
    $estimate = new Estimates();
    $estimate->retrieve($_REQUEST['estimate_id']);
    $ClientRequest = new ClientRequest();
    $ClientRequest->retrieve($estimate->clientrequest_id);
    if (isset($estimate->id) && !empty($estimate->id)) {
        $focus->product_id = $estimate->product_id;
        $focus->name = $estimate->name;
        $focus->number = 'ORD' . $focus->generate_number('number', $focus->table_name);
        $focus->estimate_id = $estimate->id;
        $focus->deadline = $estimate->deadline;
        $focus->quantity = $estimate->quantity;
        //$focus->sub_status = $estimate->sub_status;
        $focus->period = $estimate->period;
        $focus->samples = $estimate->samples;
        $focus->file = $estimate->file;
        $focus->note = $estimate->note;
Ejemplo n.º 9
0
    }
}
if (isset($_REQUEST['estimate_id']) && !empty($_REQUEST['estimate_id'])) {
    $xtpl->assign('estimate_id', $_REQUEST['estimate_id']);
    $xtpl->assign("PRODUCTROWS", $focus->add_quote_estimate($_REQUEST['estimate_id']));
    $xtpl->parse("main.row1");
    $estimate_id = $_REQUEST['estimate_id'];
}
if (isset($focus->estimate_id) && !empty($focus->estimate_id)) {
    $xtpl->assign('estimate_id', $focus->estimate_id);
    $xtpl->assign("PRODUCTROWS", $focus->add_quote_estimate($focus->estimate_id));
    $xtpl->parse("main.row1");
    $estimate_id = $focus->estimate_id;
}
if (isset($estimate_id) && !empty($estimate_id)) {
    $Estimate = new Estimates();
    $Estimate->retrieve($estimate_id);
    $product = new Products();
    $product->retrieve($Estimate->product_id);
    $xtpl->assign("number", $product->pnum);
    $xtpl->assign("prod_product_name", $product->name);
    $xtpl->assign("prod_product_id", $product->id);
    $xtpl->assign("prod_account_name", $product->account_name);
    $xtpl->assign("prod_account_id", $product->account_id);
    $xtpl->assign("prod_contact_name", $product->contact_name);
    $xtpl->assign("prod_contact_id", $product->contact_id);
    $style_display = '';
    $xtpl->assign("product_readOnly", 'readOnly');
}
if (!is_null($focus->id)) {
    $xtpl_data['ACCOUNT_ID'] = $focus->account_id;
Ejemplo n.º 10
0
 * 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/EstimateCalc/EstimateCalc.php';
require_once 'modules/Estimates/Estimates.php';
require_once 'include/formbase.php';
$sugarbean = new EstimateCalc();
$sugarbean = populateFromPost('', $sugarbean);
$sugarbean->status = "uptodate";
if (isset($_REQUEST['email_id'])) {
    $sugarbean->email_id = $_REQUEST['email_id'];
}
if (!$sugarbean->ACLAccess('Save')) {
    ACLController::displayNoAccess(true);
    sugar_cleanup(true);
}
$sugarbean->save($GLOBALS['check_notify']);
$return_id = $sugarbean->id;
$estimate = new Estimates();
$estimate->retrieve($sugarbean->estimate_id);
//// Status Update
if (isset($_REQUEST['stat_action']) && !empty($_REQUEST['stat_action']) && !is_null($_REQUEST['stat_action'])) {
    $estimate->status_update('', $estimate->id, $_REQUEST['stat_action'], '');
} else {
    $estimate->status_update('', $estimate->id, '', '');
}
/////////////////
handleRedirect($return_id, 'EstimateCalc');
Ejemplo n.º 11
0
 *    (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/Estimates/Estimates.php';
require_once 'modules/EstimateComponents/EstimateComponents.php';
require_once 'modules/ClientRequest/ClientRequest.php';
require_once 'modules/ProductStatus/ProductStatus.php';
require_once 'include/formbase.php';
$Estimates = new Estimates();
if (isset($_REQUEST['clientrequest_id']) && !empty($_REQUEST['clientrequest_id'])) {
    $ClientRequest = new ClientRequest();
    $ClientRequest->retrieve($_REQUEST['clientrequest_id']);
    $Estimates->product_id = $ClientRequest->product_id;
    $Estimates->name = $ClientRequest->name;
    $Estimates->number = 'PTR' . $Estimates->generate_number('number', $Estimates->table_name);
    $Estimates->clientrequest_id = $ClientRequest->id;
    $Estimates->deadline = $ClientRequest->due_date;
    $Estimates->quantity = $ClientRequest->quantity;
    $Estimates->status = $ClientRequest->status;
    $Estimates->period = $ClientRequest->periodic;
    $Estimates->samples = $ClientRequest->samples;
    $Estimates->file = $ClientRequest->files;
    $Estimates->note = $ClientRequest->special_requirements;
    $Estimates->description = $ClientRequest->description;
 /**
  * Prende le stime dei figli, le somma e ne genera una singola
  */
 function getEstimateFromChilds()
 {
     // Prendo tutti i figli della milestone corrente
     $tasks = Tasks::findByMilestone($this->object, STATE_VISIBLE);
     // Scorro tutti i figli e ne salvo le stime
     $estimates = array();
     $estimates_sum = 0;
     if (is_foreachable($tasks)) {
         foreach ($tasks as $task) {
             $estimate = Estimates::findLatestByParent($task);
             // Se non è stata impostata la stima ritorna nullo, quindi bisogna controllare che effettivamente l'oggetto esista
             if ($estimate && $estimate instanceof Estimate) {
                 $estimates[] = $estimate;
                 $estimates_sum += $estimate->getValue();
             }
         }
     }
     // FIXME: seconda parte dell'if inutile
     if ($this->object instanceof Milestone || $this->object instanceof RemediaMilestone) {
         $estimate = new Estimate();
         $estimate->setParent($this->object);
         $estimate->setValue($estimates_sum);
         $estimate->setJobType(JobTypes::findById(1));
         // TODO: ho preso un job a caso, chissene
         $estimate->setComment('Stima generata automaticamente');
         $estimate->setCreatedBy($this->object->assignees()->getAssignee());
         // Assegno come creatore un tizio tra gli assegnatari
         $estimate->setCreatedOn(DateTimeValue::now());
     }
     return $estimate;
 }
Ejemplo n.º 13
0
        $reportInfo = $reportObj->getReportDetails($reportId, false);
        $reports_obj = new Dynamo("reports");
        $reportsArray = $reports_obj->getAll("WHERE id = " . $reportId);
        if ($reportsArray[0]['is_submitted'] == 0) {
            ?>
			<script type="text/javascript">
				window.location.href = "edit_property.php?propertyId=<?php 
            print $propertyId;
            ?>
";
			</script>
			<?php 
            exit;
        }
    }
    $estimatesObj = new Estimates();
    $estimatesId = $estimatesObj->getPreviousEstimatesId($propertyId, false);
    $estimateInfo = $estimatesObj->getEstimateDetails($estimatesId, false);
    if (count($estimateInfo['rooms']) > 0 && count($reportInfo['rooms']) > 0) {
        $arrayRoomsExisting = array();
        for ($i = 0; $i < count($estimateInfo['rooms']); $i++) {
            $found_value = false;
            for ($j = 0; $j < count($reportInfo['rooms']); $j++) {
                if ($estimateInfo['rooms'][$i]["roomName"] == $reportInfo['rooms'][$j]["roomName"] && $estimateInfo['rooms'][$i]["roomTemplateId"] == $reportInfo['rooms'][$j]["roomTemplateId"]) {
                    //$arrayRoomsExisting[] = $reportInfo['rooms'][$j];
                    $found_value = true;
                }
            }
            if ($found_value == false) {
                for ($p = 0; $p < count($estimateInfo['rooms'][$i]['items']); $p++) {
                    for ($n = 0; $n < count($estimateInfo['rooms'][$i]['items'][$p]['arrayRoomItemsUnits']); $n++) {