}
     $query = substr($query, 0, -1);
     $subcontractors_assign_object->customExecuteQuery($query);
 }
 if ($_REQUEST['estimates'] == 'true') {
     $propertyObjDynamo = new Dynamo("properties");
     $query = "UPDATE properties SET in_estimates = 1 WHERE id = {$next_property_id}";
     $propertyObjDynamo->customExecuteQuery($query);
     $estimatesObj = new Dynamo("estimates");
     $estimateId = $estimatesObj->getMaxId();
     $query = "INSERT INTO estimates\n\t\t\t\t\t(`id`,`property_id`,`date_created`,`reported_by`,`is_submitted`,`is_saved`,`is_closed`,`report_status`)\n\t\t\t\t\tVALUES\n\t\t\t\t\t(" . $estimateId . "," . $next_property_id . ",NOW()," . $_SESSION['user_id'] . ",0,1,0,0)";
     $estimatesObj->customExecuteQuery($query);
     $query = '';
     $query_extra = '';
     $estimateRoomsObj = new Dynamo("estimate_rooms");
     $estimate_room_id = $estimateRoomsObj->getMaxId();
     if (count($community_report_room_items_array2) > 0) {
         $community_report_room_items_array = $community_report_room_items_array2;
     } else {
         $community_report_room_items_array2 = $community_report_room_items_array;
     }
     for ($j = 0; $j < count($community_report_rooms); $j++) {
         if ($j == 0) {
             $query = "INSERT INTO estimate_rooms (`id`,`estimate_id`,`room_template_id`,`name`,`date_created`,`created_by`) VALUES";
         }
         $query .= "({$estimate_room_id},{$estimateId}," . $community_report_rooms[$j]["room_template_id"] . ",\"" . $community_report_rooms[$j]["name"] . "\",NOW()," . $_SESSION['user_id'] . "),";
         for ($k = 0; $k < count($community_report_room_items_array); $k++) {
             if ($community_report_room_items_array2[$k]['room_id'] == $community_report_rooms[$j]['id']) {
                 $community_report_room_items_array[$k]['room_id'] = $estimate_room_id;
             }
         }
Exemple #2
0
$complexPropertyId = isset($_POST['complexPropertyId']) ? $_POST['complexPropertyId'] : 0;
$userId = isset($_POST['userId']) ? $_POST['userId'] : 0;
//add community reports
if ($propertyId > 0 && $complexPropertyId > 0) {
    $complex_reports_obj = new Dynamo("complex_reports");
    $complex_reports_array = $complex_reports_obj->getAll("WHERE property_id = " . $complexPropertyId);
    $community_reports_obj = new Dynamo("community_reports");
    $complex_report_rooms_obj = new Dynamo("complex_report_rooms");
    $community_report_rooms_obj = new Dynamo("community_report_rooms");
    $complex_report_room_items_obj = new Dynamo("complex_report_room_items");
    $community_report_room_items_obj = new Dynamo("community_report_room_items");
    if (count($complex_reports_array) > 0) {
        $query = "INSERT INTO community_reports(`id`,`property_id`,`date_reported`,`status_id`,`reported_by`,`is_submitted`,`is_saved`,`is_closed`) VALUES";
        $community_reports_id = $community_reports_obj->getMaxId();
        $community_report_rooms_id = $community_report_rooms_obj->getMaxId();
        $community_report_room_items_id = $community_report_room_items_obj->getMaxId();
        for ($i = 0; $i < count($complex_reports_array); $i++) {
            $query .= "({$community_reports_id},{$propertyId},NOW(),0,{$userId},0,0,0),";
            $complex_report_rooms_array = $complex_report_rooms_obj->getAll("WHERE report_id = " . $complex_reports_array[$i]["id"]);
            $complex_report_room_items_array = $complex_report_room_items_obj->getAll("WHERE report_id = " . $complex_reports_array[$i]["id"]);
            if (count($complex_report_rooms_array) > 0) {
                //add report rooms
                if (trim($query2) == '') {
                    $query2 = "INSERT INTO community_report_rooms(`id`,`report_id`,`room_template_id`,`name`,`date_created`,`created_by`) VALUES";
                }
                //add report room items
                if (count($complex_report_room_items_array) > 0 && trim($query3) == '') {
                    $query3 = "INSERT INTO community_report_room_items(`id`,`report_id`,`room_id`,`room_template_item_id`,`name`,`status_id`,`date_created`) VALUES";
                }
                for ($j = 0; $j < count($complex_report_rooms_array); $j++) {
                    $query2 .= "({$community_report_rooms_id},{$community_reports_id}," . $complex_report_rooms_array[$j]['room_template_id'] . ",'" . addslashes(stripslashes($complex_report_rooms_array[$j]['name'])) . "',NOW(),{$userId}),";
<?php

if (!isset($_SESSION)) {
    session_start();
}
define('__ROOT__', dirname(dirname(__FILE__)));
define('__BASENAME__', basename(__ROOT__));
require_once __ROOT__ . '/modules/Dynamo.class.php';
$result['success'] = false;
$result['message'] = '';
$work_category_estimates_obj = new Dynamo("work_category_estimates");
if (trim($_POST['data']) != '') {
    $arrayData = json_decode($_POST['data']);
    if (count($arrayData) > 0) {
        $query = "DELETE FROM work_category_estimates WHERE work_category_id = " . $_POST['work_category_id'];
        $work_category_estimates_obj->customExecuteQuery($query);
        $maxId = $work_category_estimates_obj->getMaxId();
        $query = "INSERT INTO work_category_estimates VALUES";
        for ($i = 0; $i < count($arrayData); $i++) {
            $query .= "({$maxId}," . $_POST['work_category_id'] . ",\"" . addslashes(stripslashes($arrayData[$i]->item_name)) . "\",\"" . $arrayData[$i]->price_per_unit . "\"," . $arrayData[$i]->unit_of_measure . ",NOW()),";
            $maxId += 1;
        }
        $query = substr($query, 0, -1);
        $work_category_estimates_obj->customExecuteQuery($query);
        $result['success'] = true;
        $result['message'] = 'Successfully added estimates';
    }
}
header('Content-type: application/json');
echo json_encode($result);
Exemple #4
0
<?php

if (!isset($_SESSION)) {
    session_start();
}
require_once dirname(dirname(__FILE__)) . '/modules/Dynamo.class.php';
require_once dirname(dirname(__FILE__)) . '/modules/FileUploader.class.php';
$report_images = new Dynamo("report_images");
$imageId = $report_images->getMaxId();
$uploader = new qqUploadedFileXhr();
$filename = $uploader->getName();
$array_file = explode(".", $filename);
$property_id = $_REQUEST['property_id'] = $_GET['propertyId'];
if (trim($_GET['reportId']) != '') {
    $report_id = $_REQUEST['report_id'] = $_GET['reportId'];
    $image_filename = $report_id . "_" . $imageId . "." . $array_file[count($array_file) - 1];
} else {
    if (trim($_GET['propertyId']) != '') {
        $_REQUEST['report_id'] = '';
        $image_filename = $property_id . "_" . $imageId . "." . $array_file[count($array_file) - 1];
    }
}
$result = $uploader->save(dirname(dirname(__FILE__)) . '/images/report_uploads/' . $image_filename);
if ($result) {
    $_REQUEST['image_name'] = $image_filename;
    $_REQUEST['date'] = date("Y-m-d H:i:s", time());
    $_REQUEST['user_id'] = $_SESSION['user_id'];
    $array_images_exist = array();
    $array_images_exist = $report_images->getAll("WHERE property_id = " . $property_id);
    if (count($array_images_exist) > 0) {
        $_REQUEST['property_image'] = 0;
Exemple #5
0
 if (count($array_data) > 0) {
     for ($i = 0; $i < count($array_data); $i++) {
         $_REQUEST['room_template_id'] = $array_data[$i]->roomTemplateId;
         $_REQUEST['name'] = $array_data[$i]->roomName;
         $_REQUEST['date_created'] = date("Y-m-d H:i:s", time());
         $_REQUEST['room_id'] = $complex_report_rooms_object->getMaxId();
         if ($complex_report_rooms_object->add()) {
             for ($j = 0; $j < count($array_data[$i]->roomItems); $j++) {
                 $roomItems = $array_data[$i]->roomItems;
                 $_REQUEST['room_template_item_id'] = $roomItems[$j]->roomTemplateItemId;
                 $_REQUEST['name'] = $roomItems[$j]->name;
                 $_REQUEST['status_id'] = $roomItems[$j]->statusId;
                 $_REQUEST['work_category_id'] = $roomItems[$j]->work_category_id;
                 $_REQUEST['date'] = $_REQUEST['date_created'] = date("Y-m-d H:i:s", time());
                 $_REQUEST['comment'] = $roomItems[$j]->comment;
                 $complex_report_room_items_id = $complex_report_room_items_object->getMaxId();
                 if ($complex_report_room_items_object->add()) {
                     if (trim($_REQUEST['comment']) != '') {
                         $_REQUEST['room_item_id'] = $complex_report_room_items_id;
                         if ($complex_report_room_item_comments->add()) {
                         } else {
                             $result['success'] = false;
                             $result['message'] = 'Sorry, there has been a problem processing your request.';
                         }
                     }
                 } else {
                     $result['success'] = false;
                     $result['message'] = 'Sorry, there has been a problem processing your request.';
                 }
             }
         } else {
 $complex_reports_array = $complex_reports_obj->getOneWhere("property_id = " . $complex_properties_array["id"]);
 $_REQUEST['date_reported'] = date("Y-m-d H:i:s");
 $_REQUEST['status_id'] = $_REQUEST['is_submitted'] = $_REQUEST['is_closed'] = $_REQUEST['subcontractor'] = 0;
 $_REQUEST['is_saved'] = 1;
 $_REQUEST['report_id'] = $community_report_id = $reports_obj->getMaxId();
 if ($reports_obj->add()) {
     $report_rooms_obj = new Dynamo("report_rooms");
     $report_rooms_max_id = $report_rooms_obj->getMaxId();
     $complex_report_rooms_obj = new Dynamo("complex_report_rooms");
     $complex_report_rooms_array = $complex_report_rooms_obj->getAll("WHERE report_id = " . $complex_reports_array["id"] . " ORDER BY id");
     if (count($complex_report_rooms_array) > 0) {
         $query = "INSERT INTO report_rooms (`id`,`report_id`,`room_template_id`,`name`,`date_created`,`created_by`) VALUES";
         $complex_report_room_items_obj = new Dynamo("complex_report_room_items");
         $complex_report_room_items_array = $complex_report_room_items_obj->getAll("WHERE report_id = " . $complex_report_rooms_array[0]["report_id"] . " ORDER BY id");
         $report_room_items_obj = new Dynamo("report_room_items");
         $report_room_items_max_id = $report_room_items_obj->getMaxId();
         if (count($complex_report_room_items_array) > 0) {
             $query2 = "INSERT INTO report_room_items (`id`,`report_id`,`room_id`,`room_template_item_id`,`name`,`status_id`,`date_created`) VALUES";
         }
         for ($i = 0; $i < count($complex_report_rooms_array); $i++) {
             $query .= "({$report_rooms_max_id}," . $_REQUEST['report_id'] . "," . $complex_report_rooms_array[$i]["room_template_id"] . ",'" . addslashes(stripslashes($complex_report_rooms_array[$i]["name"])) . "',NOW()," . $_SESSION['user_id'] . "),";
             for ($j = 0; $j < count($complex_report_room_items_array); $j++) {
                 if ($complex_report_room_items_array[$j]["room_id"] == $complex_report_rooms_array[$i]["id"]) {
                     $query2 .= "({$report_room_items_max_id}," . $_REQUEST['report_id'] . ",{$report_rooms_max_id}," . $complex_report_room_items_array[$j]["room_template_item_id"] . ",'" . addslashes(stripslashes($complex_report_room_items_array[$j]["name"])) . "'," . $complex_report_room_items_array[$j]["status_id"] . ",NOW()),";
                     $report_room_items_max_id += 1;
                 }
             }
             $report_rooms_max_id += 1;
         }
         if (trim($query) != '') {
             $query = substr($query, 0, -1);
<?php

if (!isset($_SESSION)) {
    session_start();
}
define('__ROOT__', dirname(dirname(__FILE__)));
define('__BASENAME__', basename(__ROOT__));
require_once __ROOT__ . '/modules/Dynamo.class.php';
$result['success'] = false;
$result['message'] = '';
$room_template_estimates_obj = new Dynamo("room_template_estimates");
if (trim($_POST['data']) != '') {
    $arrayData = json_decode($_POST['data']);
    if (count($arrayData) > 0) {
        $query = "DELETE FROM room_template_estimates WHERE room_template_items_id = " . $_POST['room_template_items_id'];
        $room_template_estimates_obj->customExecuteQuery($query);
        $maxId = $room_template_estimates_obj->getMaxId();
        $query = "INSERT INTO room_template_estimates VALUES";
        for ($i = 0; $i < count($arrayData); $i++) {
            $query .= "({$maxId}," . $_POST['room_template_id'] . "," . $_POST['room_template_items_id'] . ",\"" . addslashes(stripslashes($arrayData[$i]->item_name)) . "\",\"" . $arrayData[$i]->price_per_unit . "\"," . $arrayData[$i]->unit_of_measure . ",NOW()),";
            $maxId += 1;
        }
        $query = substr($query, 0, -1);
        $room_template_estimates_obj->customExecuteQuery($query);
        $result['success'] = true;
        $result['message'] = 'Successfully added estimates';
    }
}
header('Content-type: application/json');
echo json_encode($result);
Exemple #8
0
 $estimatesId = $_REQUEST['estimatesId'] = $estimates_obj->getMaxId();
 $room_template_items_array = $room_template_items_obj->getAll();
 $query = "INSERT INTO estimates (`id`,`property_id`,`date_created`,`reported_by`,`is_submitted`,`is_saved`,`is_closed`) \n\t\tVALUES(" . $_REQUEST['estimatesId'] . "," . $estimateInfo['propertyId'] . ",NOW()," . $_SESSION['user_id'] . ",1,0,2)";
 $estimates_obj->customExecuteQuery($query);
 if (count($estimateInfo['rooms']) > 0) {
     $query = "INSERT INTO estimate_rooms VALUES";
     $query2 = "INSERT INTO estimate_room_items (`id`,`estimate_id`,`room_id`,`room_template_item_id`,`name`,`date_created`) VALUES";
     if (count($estimate_room_items_units_array) > 0) {
         $query3 = "INSERT INTO estimate_room_items_units VALUES";
     }
     $query_first = false;
     $query_second = false;
     $query_third = false;
     $maxIdEstimateRooms = $estimate_rooms_obj->getMaxId();
     $estimateRoomMaxId = $estimate_room_items_obj->getMaxId();
     $estimateRoomItemsUnitsMaxId = $estimate_room_items_units_obj->getMaxId();
     for ($i = 0; $i < count($estimateInfo['rooms']); $i++) {
         $query_first = true;
         $query .= "({$maxIdEstimateRooms}," . $_REQUEST['estimatesId'] . "," . $estimateInfo['rooms'][$i]['roomTemplateId'] . ",\"" . addslashes(stripslashes($estimateInfo['rooms'][$i]['roomName'])) . "\",NOW()," . $_SESSION['user_id'] . "),";
         for ($j = 0; $j < count($estimateInfo['rooms'][$i]['items']); $j++) {
             for ($k = 0; $k < count($room_template_items_array); $k++) {
                 if ($room_template_items_array[$k]['name'] == $estimateInfo['rooms'][$i]['items'][$j]['itemName'] && $estimateInfo['rooms'][$i]['roomTemplateId'] == $room_template_items_array[$k]['room_template_id']) {
                     $room_template_items_id = $room_template_items_array[$k]['id'];
                     break;
                 }
             }
             $query_second = true;
             $query2 .= "(" . $estimateRoomMaxId . "," . $_REQUEST['estimatesId'] . ",{$maxIdEstimateRooms}," . $room_template_items_id . ",'" . addslashes(stripslashes($estimateInfo['rooms'][$i]['items'][$j]['itemName'])) . "',NOW()),";
             if (count($estimate_room_items_units_array) > 0) {
                 for ($k = 0; $k < count($estimate_room_items_units_array); $k++) {
                     if ($estimate_room_items_units_array[$k]['estimate_room_items_id'] == $estimateInfo['rooms'][$i]['items'][$j]['itemId']) {
$complexPropertyId = isset($_POST['complexPropertyId']) ? $_POST['complexPropertyId'] : 0;
$userId = isset($_POST['userId']) ? $_POST['userId'] : 0;
//add community reports
if ($propertyId > 0 && $complexPropertyId > 0) {
    $complex_estimates_obj = new Dynamo("complex_reports");
    $complex_reports_array = $complex_estimates_obj->getAll("WHERE property_id = " . $complexPropertyId);
    $estimates_obj = new Dynamo("estimates");
    $complex_estimate_rooms_obj = new Dynamo("complex_report_rooms");
    $estimate_rooms_obj = new Dynamo("estimate_rooms");
    $complex_estimate_room_items_obj = new Dynamo("complex_report_room_items");
    $estimate_room_items_obj = new Dynamo("estimate_room_items");
    if (count($complex_reports_array) > 0) {
        $query = "INSERT INTO estimates(`id`,`property_id`,`date_created`,`reported_by`,`is_submitted`,`is_saved`,`is_closed`,`report_status`) VALUES";
        $estimate_id = $estimates_obj->getMaxId();
        $estimate_rooms_id = $estimate_rooms_obj->getMaxId();
        $estimate_room_items_id = $estimate_room_items_obj->getMaxId();
        for ($i = 0; $i < count($complex_reports_array); $i++) {
            $query .= "({$estimate_id},{$propertyId},NOW(),{$userId},0,1,0,0),";
            $complex_report_rooms_array = $complex_estimate_rooms_obj->getAll("WHERE report_id = " . $complex_reports_array[$i]["id"]);
            $complex_report_room_items_array = $complex_estimate_room_items_obj->getAll("WHERE report_id = " . $complex_reports_array[$i]["id"]);
            if (count($complex_report_rooms_array) > 0) {
                //add report rooms
                if (trim($query2) == '') {
                    $query2 = "INSERT INTO estimate_rooms(`id`,`estimate_id`,`room_template_id`,`name`,`date_created`,`created_by`) VALUES";
                }
                //add report room items
                if (count($complex_report_room_items_array) > 0 && trim($query3) == '') {
                    $query3 = "INSERT INTO estimate_room_items(`id`,`estimate_id`,`room_id`,`room_template_item_id`,`name`,`date_created`) VALUES";
                }
                for ($j = 0; $j < count($complex_report_rooms_array); $j++) {
                    $query2 .= "({$estimate_rooms_id},{$estimate_id}," . $complex_report_rooms_array[$j]['room_template_id'] . ",'" . addslashes(stripslashes($complex_report_rooms_array[$j]['name'])) . "',NOW(),{$userId}),";
$data = $roomObj->getRoomTemplateItems($id, false);
$array_room_templates = $room_templates_obj->getOne();
$maxIdEstimateRooms = $estimate_rooms_obj->getMaxId();
ob_start();
if (trim($_REQUEST['estimatesId']) == '' && trim($_REQUEST['propertyId']) != '') {
    $_REQUEST['estimatesId'] = $estimates_obj->getMaxId();
    $query = "INSERT INTO estimates (`id`,`property_id`,`date_created`,`reported_by`,`is_submitted`,`is_saved`,`is_closed`) \n\tVALUES(" . $_REQUEST['estimatesId'] . "," . $_REQUEST['propertyId'] . ",NOW()," . $_SESSION['user_id'] . ",0,1,0)";
    $estimates_obj->customExecuteQuery($query);
    $query = "UPDATE properties SET in_estimates = 1 WHERE id = " . $_REQUEST['propertyId'];
    $property_obj->customExecuteQuery($query);
}
if (count($data) > 0) {
    $query = "INSERT INTO estimate_rooms VALUES({$maxIdEstimateRooms}," . $_REQUEST['estimatesId'] . ",{$id},'" . htmlentities(html_entity_decode($_REQUEST['roomName']), ENT_QUOTES) . "',NOW()," . $_SESSION['user_id'] . ")";
    $room_templates_obj->customExecuteQuery($query);
    $result['roomId'] = $maxIdEstimateRooms;
    $query = "INSERT INTO estimate_room_items (`id`,`estimate_id`,`room_id`,`room_template_item_id`,`name`,`date_created`) VALUES";
    $reportRoomMaxId = $estimate_room_items_obj->getMaxId();
    for ($i = 0; $i < count($data); $i++) {
        $query .= "(" . $reportRoomMaxId . "," . $_REQUEST['estimatesId'] . ",{$maxIdEstimateRooms}," . $data[$i]['roomTemplateItemId'] . ",'" . addslashes(stripslashes($data[$i]['name'])) . "',NOW()),";
        $data[$i]['roomId'] = $maxIdEstimateRooms;
        $data[$i]['itemId'] = $reportRoomMaxId;
        $data[$i]['estimatesId'] = $_REQUEST['estimatesId'];
        $reportRoomMaxId += 1;
    }
    $query = substr($query, 0, -1);
    $estimate_room_items_obj->customExecuteQuery($query);
    $result['success'] = true;
    $result['data'] = $data;
}
header('Content-type: application/json');
echo json_encode($result);
Exemple #11
0
 $reportId = $_REQUEST['reportId'] = $reports_obj->getMaxId();
 $room_template_items_array = $room_template_items_obj->getAll();
 if ($_SESSION['user_type'] == 5) {
     $subcontractor = 1;
 } else {
     $subcontractor = 0;
 }
 $query = "INSERT INTO reports (`id`,`property_id`,`date_reported`,`status_id`,`reported_by`,`is_submitted`,`is_saved`,`is_closed`,`subcontractor`) \n\t\tVALUES(" . $_REQUEST['reportId'] . "," . $reportInfo['propertyId'] . ",NOW(),0," . $_SESSION['user_id'] . ",0,1,0,{$subcontractor})";
 $reports_obj->customExecuteQuery($query);
 if (count($reportInfo['rooms']) > 0) {
     $query = "INSERT INTO report_rooms VALUES";
     $query2 = "INSERT INTO report_room_items (`id`,`report_id`,`room_id`,`room_template_item_id`,`name`,`status_id`,`is_estimate`,`date_created`) VALUES";
     $query_first = false;
     $query_second = false;
     $maxIdReportRooms = $report_rooms_obj->getMaxId();
     $reportRoomMaxId = $report_room_items_obj->getMaxId();
     for ($i = 0; $i < count($reportInfo['rooms']); $i++) {
         if (count($reportInfo['rooms'][$i]['items']) <= 0) {
             continue;
         }
         $query_first = true;
         $query .= "({$maxIdReportRooms}," . $_REQUEST['reportId'] . "," . $reportInfo['rooms'][$i]['roomTemplateId'] . ",\"" . $reportInfo['rooms'][$i]['roomName'] . "\",NOW()," . $_SESSION['user_id'] . "),";
         for ($j = 0; $j < count($reportInfo['rooms'][$i]['items']); $j++) {
             if ($new_report) {
                 for ($k = 0; $k < count($room_template_items_array); $k++) {
                     if ($room_template_items_array[$k]['name'] == $reportInfo['rooms'][$i]['items'][$j]['itemName'] && $reportInfo['rooms'][$i]['roomTemplateId'] == $room_template_items_array[$k]['room_template_id']) {
                         $room_template_items_id = $room_template_items_array[$k]['id'];
                         break;
                     }
                 }
             } else {
Exemple #12
0
";
		</script>
        <?php 
        exit;
    }
    $_REQUEST['id'] = $_REQUEST["propertyId"];
    $propertiesObject = new Dynamo("properties");
    $propertyArray = $propertiesObject->getOne();
} else {
    print "You'll need property ID in order to proceed";
    exit;
}
if (trim($_POST["company"]) != '' && trim($_POST["report_no"]) != '' && trim($_POST["log_date"]) != '' && trim($_POST["project_community"]) != '' && trim($_POST["total_field_workers"]) != '' && trim($_POST["superintendent"]) != '' && trim($_POST["weather"]) != '') {
    $log_date = strtotime($_REQUEST['log_date']);
    $_REQUEST['log_date'] = date("Y-m-d", $log_date);
    $_REQUEST['daily_logs_id'] = $maxId = $dailyLogsObject->getMaxId();
    $_REQUEST['user_id'] = $_SESSION['user_id'];
    if ($dailyLogsObject->add()) {
        for ($i = 1; $i < 30000; $i++) {
            if (trim($_REQUEST['notes_' . $i]) != '' || trim($_REQUEST['lot_' . $i]) != '') {
                $_REQUEST["lot"] = $_REQUEST["lot_" . $i];
                $_REQUEST["job_status"] = $_REQUEST["job_status_" . $i];
                $_REQUEST["notes"] = $_REQUEST["notes_" . $i];
                if ($_REQUEST["weather_delay_" . $i]) {
                    $_REQUEST["weather_delay"] = 1;
                } else {
                    $_REQUEST["weather_delay"] = 0;
                }
                if ($_REQUEST["missed_inspection_" . $i]) {
                    $_REQUEST["missed_inspection"] = 1;
                } else {
<?php

define('__ROOT__', dirname(dirname(__FILE__)));
define('__BASENAME__', basename(__ROOT__));
require_once __ROOT__ . '/modules/Dynamo.class.php';
$_REQUEST['date_created'] = date("Y-m-d H:i:s");
if (trim($_REQUEST['email']) != '' && trim($_REQUEST['first_name']) != '' && trim($_REQUEST['last_name']) != '' && trim($_REQUEST['phone_number']) != '') {
    $subContractorObj = new Dynamo("sub_contractors");
    $sub_contractor_id = $subContractorObj->getMaxId();
    if ($subContractorObj->add()) {
        if (trim($_REQUEST['work_category_id_string']) != '') {
            $array_work_category = array();
            $work_category_id_string = substr($_REQUEST['work_category_id_string'], 0, -1);
            if (stristr($work_category_id_string, ",")) {
                $array_work_category = explode(",", $work_category_id_string);
            } else {
                $array_work_category[] = $work_category_id_string;
            }
            $query = "INSERT INTO sub_contractor_work_category VALUES";
            for ($i = 0; $i < count($array_work_category); $i++) {
                $query .= "({$sub_contractor_id}," . $array_work_category[$i] . ",NOW()),";
            }
            $query = substr($query, 0, -1);
            if ($subContractorObj->customExecuteQuery($query)) {
                $result['success'] = true;
                $result['message'] = 'Sub contractor successfully added!';
            }
        } else {
            $result['success'] = true;
            $result['message'] = 'Sub contractor successfully added!';
        }
}
if (trim($_REQUEST['subcontractor_details']) != '') {
    $subcontractor_details_array = json_decode($_REQUEST['subcontractor_details']);
    if (count($subcontractor_details_array) > 0) {
        $query = "INSERT INTO subcontractors_assign (`sub_contractor_id`,`property_id`,`work_category_id`) VALUES";
        for ($i = 0; $i < count($subcontractor_details_array); $i++) {
            $query .= "(" . $subcontractor_details_array[$i]->subcontractorId . "," . $_REQUEST['propertyId'] . "," . $_REQUEST['work_category_id'] . "),";
        }
        $query = substr($query, 0, -1);
        $subcontractors_assign_obj->customExecuteQuery($query);
    }
}
if (trim($_POST['data']) != '') {
    $arrayData = json_decode($_POST['data']);
    if (count($arrayData) > 0) {
        $maxId = $estimate_room_items_units_obj->getMaxId();
        $query = '';
        $query2 = '';
        for ($i = 0; $i < count($arrayData); $i++) {
            if ($arrayData[$i]->estimate_room_items_units_id == 0) {
                if (trim($query) == '') {
                    $query = "INSERT INTO estimate_room_items_units VALUES";
                }
                $query .= "({$maxId}," . $_POST['estimate_id'] . "," . $_POST['room_id'] . "," . $_REQUEST['estimate_room_items_id'] . "," . $arrayData[$i]->work_category_estimates_id . ",\"" . $arrayData[$i]->unit_value . "\",\"" . $arrayData[$i]->price_per_unit . "\",\"" . addslashes(stripslashes($arrayData[$i]->scope)) . "\",2,NOW()),";
                $maxId += 1;
            } else {
                $query2 = "UPDATE estimate_room_items_units SET units = \"" . $arrayData[$i]->unit_value . "\",price_per_unit = \"" . $arrayData[$i]->price_per_unit . "\",scope = \"" . addslashes(stripslashes($arrayData[$i]->scope)) . "\" WHERE estimate_id = " . $_POST['estimate_id'] . " AND estimate_room_items_id = " . $_POST['estimate_room_items_id'] . " AND  work_category_estimates_id = " . $arrayData[$i]->work_category_estimates_id . " AND room_id = " . $_POST['room_id'];
                $estimate_room_items_units_obj->customExecuteQuery($query2);
                $query2 = '';
            }
        }
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/modules/Dynamo.class.php';
if (trim($_GET['userId']) != '') {
    $user_properties_obj = new Dynamo("user_properties");
    if ($_POST['assign_properties'] == 1) {
        $query = "DELETE FROM user_properties WHERE user_id = " . $_GET['userId'];
        $user_properties_obj->customExecuteQuery($query);
        $user_properties_id = $user_properties_obj->getMaxId();
        if (count($_POST['propertyId']) > 0) {
            $query = "INSERT INTO user_properties (`id`,`user_id`,`property_id`,`timestamp`) VALUES";
            for ($i = 0; $i < count($_POST['propertyId']); $i++) {
                $query .= "({$user_properties_id}," . $_GET['userId'] . "," . $_POST['propertyId'][$i] . ",NOW()),";
            }
            $query = substr($query, 0, -1);
            $user_properties_obj->customExecuteQuery($query);
        }
    }
    $users_obj = new Dynamo("users");
    $userArray = $users_obj->getAll("WHERE id = " . $_GET['userId']);
    $userArray = $userArray[0];
    $properties_obj = new Dynamo("properties");
    $propertyArray = $properties_obj->getAll("WHERE status = 1");
    $userPropertiesArray = $user_properties_obj->getAll("WHERE user_id = " . $_GET['userId']);
    $userPropertyArray = array();
    for ($i = 0; $i < count($userPropertiesArray); $i++) {
        $userPropertyArray[] = $userPropertiesArray[$i]['property_id'];
    }
    ?>
	<form method="POST" class="form-horizontal" id="addUserForm">
	<div class="pull-left"><h4>Assign Properties to <?php