Beispiel #1
0
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/modules/Dynamo.class.php';
if (trim($_REQUEST['id']) != '') {
    $unitsObj = new Dynamo("units");
    $unit_array = $unitsObj->getOne();
    if (count($unit_array) > 0) {
        ?>
		<form method="POST" class="form-horizontal" id="unitForm">
		<input type="hidden" id="baseName" name="baseName" value="<?php 
        echo __BASENAME__;
        ?>
" />
		<input type="hidden" id="id" name="id" value="<?php 
        print $unit_array['id'];
        ?>
" />
		<div class="pull-left"><h4>Edit Unit</h4></div>
		<div class="pull-right"><button class="btn btn-warning" type="submit">Submit Changes</button> &nbsp; <a href="units.html" class="btn btn-default">Cancel</a></div>
		<div class="clearfix"></div>
		
		<div id="status-message"></div>
		
		<div class="control-group">
			<label for="email" class="control-label">Estimate Unit</label>
			<div class="controls">
				<input type="text" name="estimate_unit" id="estimate_unit" class="form-control" placeholder="Estimate Unit" value="<?php 
        print $unit_array['estimate_unit'];
        ?>
" data-validation="required" data-validation-error-msg="Please enter a unit name."  />
			</div>
Beispiel #2
0
 public function getReportDetails($reportId, $isJson = true, $array_users = false, $array_sub_contractors = false)
 {
     $result['success'] = false;
     $result['message'] = '';
     $result['data'] = '';
     $data = array();
     $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
     if ($mysqli->connect_errno) {
         $result['message'] = "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
     }
     $propertyId = 0;
     $sql = "SELECT\t\n\t\t\t properties.id\n\t\t\t,properties.name\n\t\t\t,properties.address\n\t\t\t,properties.city\n\t\t\t,properties.state\n\t\t\t,properties.map_link\n\t\t\t,properties.emails\n\t\t\t,properties.property_type\n\t\t\t,properties.job_type\n\t\t\t,properties.community\n\t\t\t,reports.status_id\n\t\t\t,reports.date_reported\n\t\t\t,reports.reported_by\n\t\t\t,reports.subcontractor\n\t\tFROM reports\n\t\t\tINNER JOIN properties ON properties.id = reports.property_id\n\t\tWHERE reports.id = ?\n\t\t";
     $placeholder = $reportId;
     if ($stmt = $mysqli->prepare($sql)) {
         $stmt->bind_param("i", $placeholder);
         if ($stmt->execute()) {
             $stmt->bind_result($propertyId, $propertyName, $propertyAddress, $propertyCity, $propertyState, $propertyMapLink, $propertyEmails, $propertyType, $propertyJobType, $propertyCommunity, $reportStatusId, $reportDate, $reported_by, $subcontractor);
             while ($stmt->fetch()) {
                 if ($subcontractor == 1) {
                     $data = array('propertyId' => $propertyId, 'propertyName' => $propertyName, 'propertyAddress' => $propertyAddress, 'propertyCity' => $propertyCity, 'propertyState' => $propertyState, 'propertyMapLink' => $propertyMapLink, 'propertyEmails' => $propertyEmails, 'propertyType' => $propertyType, 'propertyJobType' => $propertyJobType, 'propertyCommunity' => $propertyCommunity, 'reportStatusId' => $reportStatusId, 'firstName' => $array_sub_contractors[$reported_by]['first_name'], 'lastName' => $array_sub_contractors[$reported_by]['last_name'], 'reportDate' => $reportDate, 'reported_by' => $reported_by, 'subcontractor' => $subcontractor);
                 } else {
                     $data = array('propertyId' => $propertyId, 'propertyName' => $propertyName, 'propertyAddress' => $propertyAddress, 'propertyCity' => $propertyCity, 'propertyState' => $propertyState, 'propertyMapLink' => $propertyMapLink, 'propertyEmails' => $propertyEmails, 'propertyType' => $propertyType, 'propertyJobType' => $propertyJobType, 'propertyCommunity' => $propertyCommunity, 'reportStatusId' => $reportStatusId, 'firstName' => $array_users[$reported_by]['first_name'], 'lastName' => $array_users[$reported_by]['last_name'], 'reportDate' => $reportDate, 'reported_by' => $reported_by, 'subcontractor' => $subcontractor);
                 }
             }
         }
         if ($propertyId == 0) {
             $propertyId = $_REQUEST['propertyId'];
             if (trim($propertyId) != '') {
                 $placeholder = $propertyId;
                 $sql = "SELECT\t\n\t\t\t\t\t\t\t\t properties.id\n\t\t\t\t\t\t\t\t,properties.name\n\t\t\t\t\t\t\t\t,properties.address\n\t\t\t\t\t\t\t\t,properties.city\n\t\t\t\t\t\t\t\t,properties.state\n\t\t\t\t\t\t\t\t,properties.map_link\n\t\t\t\t\t\t\t\t,properties.emails\n\t\t\t\t\t\t\t\t,properties.property_type\n\t\t\t\t\t\t\t\t,properties.job_type\n\t\t\t\t\t\t\t\t,properties.community\n\t\t\t\t\t\t\t\t,reports.status_id\n\t\t\t\t\t\t\t\t,reports.date_reported\n\t\t\t\t\t\t\t\t,reports.reported_by\n\t\t\t\t\t\t\t\t,reports.subcontractor\n\t\t\t\t\t\t\tFROM reports\n\t\t\t\t\t\t\tINNER JOIN properties ON properties.id = reports.property_id\n\t\t\t\t\t\t\tWHERE properties.id = ?\n\t\t\t\t\t\t\t";
                 $placeholder = $propertyId;
                 if ($stmt = $mysqli->prepare($sql)) {
                     $stmt->bind_param("i", $placeholder);
                     if ($stmt->execute()) {
                         $stmt->bind_result($propertyId, $propertyName, $propertyAddress, $propertyCity, $propertyState, $propertyMapLink, $propertyEmails, $propertyType, $propertyJobType, $propertyCommunity, $reportStatusId, $reportDate, $reported_by, $subcontractor);
                         while ($stmt->fetch()) {
                             if ($subcontractor == 1) {
                                 $data = array('propertyId' => $propertyId, 'propertyName' => $propertyName, 'propertyAddress' => $propertyAddress, 'propertyCity' => $propertyCity, 'propertyState' => $propertyState, 'propertyMapLink' => $propertyMapLink, 'propertyEmails' => $propertyEmails, 'propertyType' => $propertyType, 'propertyJobType' => $propertyJobType, 'propertyCommunity' => $propertyCommunity, 'reportStatusId' => $reportStatusId, 'firstName' => $array_sub_contractors[$reported_by]['first_name'], 'lastName' => $array_sub_contractors[$reported_by]['last_name'], 'reportDate' => $reportDate, 'reported_by' => $reported_by, 'subcontractor' => $subcontractor);
                             } else {
                                 $data = array('propertyId' => $propertyId, 'propertyName' => $propertyName, 'propertyAddress' => $propertyAddress, 'propertyCity' => $propertyCity, 'propertyState' => $propertyState, 'propertyMapLink' => $propertyMapLink, 'propertyEmails' => $propertyEmails, 'propertyType' => $propertyType, 'propertyJobType' => $propertyJobType, 'propertyCommunity' => $propertyCommunity, 'reportStatusId' => $reportStatusId, 'firstName' => $array_users[$reported_by]['first_name'], 'lastName' => $array_users[$reported_by]['last_name'], 'reportDate' => $reportDate, 'reported_by' => $reported_by, 'subcontractor' => $subcontractor);
                             }
                         }
                     }
                 }
             }
         }
         $stmt->close();
         //get estimates
         $query = "SELECT MAX(id) AS id FROM estimates WHERE property_id = " . $data['propertyId'];
         $estimatesObj = new Dynamo("estimates");
         $arrayEstimate = $estimatesObj->customFetchOne($query);
         $estimateId = $arrayEstimate['id'];
         //GET ROOMS AND ITEMS
         $rooms = array();
         $roomsSql = "SELECT\n\t\t\t\t\t\t\t report_rooms.id AS roomId\n\t\t\t\t\t\t\t,report_rooms.room_template_id\n\t\t\t\t\t\t\t,report_rooms.name AS roomName\n\t\t\t\t\t\tFROM report_rooms\n\t\t\t\t\t\tWHERE report_rooms.report_id = " . $reportId . "\n\t\t\t\t\t\tORDER BY report_rooms.id\n\t\t\t\t\t";
         $rooms = array();
         $dynamo = new Dynamo("report_rooms");
         //all room information
         $rooms = $dynamo->customFetchQuery($roomsSql);
         if (count($rooms) > 0) {
             //get room ids
             $arrayRoomIds = array();
             for ($i = 0; $i < count($rooms); $i++) {
                 $rooms[$i]['roomTemplateId'] = $rooms[$i]['room_template_id'];
                 $arrayRoomIds[] = $rooms[$i]['roomId'];
                 $arrayRoomName[] = $rooms[$i]['roomName'];
             }
             $stringRoomIds = implode(",", $arrayRoomIds);
             $stringRoomName = "\"" . implode("\",\"", $arrayRoomName) . "\"";
             //get room items
             $roomItems = array();
             $itemsSql = "SELECT\n\t\t\t\t\t\t\t\t report_room_items.id AS itemId\n\t\t\t\t\t\t\t\t,report_room_items.room_id\n\t\t\t\t\t\t\t\t,report_room_items.room_template_item_id AS itemTemplateId\n\t\t\t\t\t\t\t\t,report_room_items.name AS itemName\n\t\t\t\t\t\t\t\t,report_room_items.status_id AS statusId\n\t\t\t\t\t\t\t\t,report_room_items.is_estimate AS isEstimate\n\t\t\t\t\t\t\t\t,report_status.class AS statusClass\n\t\t\t\t\t\t\t\t,report_status.name AS statusName\n\t\t\t\t\t\t\t\t,room_template_items.work_category_id AS work_category_id\n\t\t\t\t\t\t\tFROM report_room_items\n\t\t\t\t\t\t\t   LEFT JOIN report_status \n\t\t\t\t\t\t\t\t\t\t  ON report_status.id = report_room_items.status_id\n\t\t\t\t\t\t\tINNER JOIN room_template_items ON room_template_items.id = report_room_items.room_template_item_id\n\t\t\t\t\t\t\tWHERE report_room_items.room_id IN (" . $stringRoomIds . ")\n\t\t\t\t\t\t\tORDER BY report_room_items.name\n\t\t\t\t\t\t";
             $roomItems = $dynamo->customFetchQuery($itemsSql);
             if (count($roomItems) > 0) {
                 $query = '';
                 $itemIdArray = array();
                 $arrayRoomName = array();
                 $arrayTemplateId = array();
                 for ($i = 0; $i < count($roomItems); $i++) {
                     $itemIdArray[] = $roomItems[$i]['itemId'];
                     $itemNameArray[] = $roomItems[$i]['itemName'];
                     $arrayTemplateId[] = $roomItems[$i]['itemTemplateId'];
                     if ($estimateId > 0 && $roomItems[$i]['isEstimate'] == 0) {
                         for ($j = 0; $j < count($rooms); $j++) {
                             if ($rooms[$j]['roomId'] == $roomItems[$i]['room_id']) {
                                 $arrayRoomName[] = $rooms[$j]['roomName'];
                                 //break;
                             }
                         }
                     }
                 }
                 if (count($arrayRoomName) > 0) {
                     //Get estimate line items
                     $query = "SELECT estimate_room_items_units.id AS estimate_room_items_units_id,\n\t\t\t\t\t\testimate_room_items_units.status_id,room_template_estimates.item_name, \n\t\t\t\t\t\testimate_room_items.room_id,estimate_room_items.room_template_item_id\n\t\t\t\t\t\tFROM estimate_room_items_units INNER JOIN estimate_room_items \n\t\t\t\t\t\tON estimate_room_items_units.estimate_room_items_id = estimate_room_items.id\n\t\t\t\t\t\tINNER JOIN room_template_estimates \n\t\t\t\t\t\tON room_template_estimates.id = estimate_room_items_units.room_template_estimates_id\n\t\t\t\t\t\tINNER JOIN estimate_rooms ON estimate_rooms.id = estimate_room_items_units.room_id\n\t\t\t\t\t\tWHERE estimate_room_items.room_template_item_id IN(" . implode(",", $arrayTemplateId) . ") \n\t\t\t\t\t\tAND estimate_room_items.estimate_id = " . $estimateId . " \n\t\t\t\t\t\tAND estimate_room_items_units.estimate_id = " . $estimateId . " \n\t\t\t\t\t\tAND estimate_rooms.name IN(\"" . implode("\",\"", $arrayRoomName) . "\")";
                     $array_room_items_unit = array();
                     $array_room_items_unit = $dynamo->customFetchQuery($query);
                     for ($i = 0; $i < count($array_room_items_unit); $i++) {
                         for ($j = 0; $j < count($roomItems); $j++) {
                             if ($array_room_items_unit[$i]['room_template_item_id'] == $roomItems[$j]['itemTemplateId'] && $roomItems[$j]['itemName'] != $array_room_items_unit[$i]['item_name']) {
                                 //if($array_room_items_unit[$i]['room_template_item_id'] == $roomItems[$j]['itemTemplateId'])
                                 $roomItems[$j]['arrayRoomItemsUnits'][] = $array_room_items_unit[$i];
                             }
                         }
                     }
                 }
                 $itemIdString = implode(",", $itemIdArray);
                 $itemNameString = "\"" . implode("\",\"", $itemNameArray) . "\"";
                 //GET THE LAST ITEM COMMENT
                 $commentsSql = "SELECT\n\t\t\t\t\t\t\t\t\t\t report_room_item_comments.id\n\t\t\t\t\t\t\t\t\t\t,report_room_item_comments.comment\n\t\t\t\t\t\t\t\t\t\t,report_room_item_comments.date AS commentDate\n\t\t\t\t\t\t\t\t\t\t,report_room_item_comments.room_item_id\n\t\t\t\t\t\t\t\t\t\t,report_room_item_comments.order\n\t\t\t\t\t\t\t\t\tFROM report_room_item_comments\n\t\t\t\t\t\t\t\t\tWHERE report_room_item_comments.room_item_id IN(" . $itemIdString . ")\n\t\t\t\t\t\t\t\t\tORDER BY report_room_item_comments.`order`";
                 $arrComments = $dynamo->customFetchQuery($commentsSql);
                 if (count($arrComments) > 0) {
                     for ($i = 0; $i < count($arrComments); $i++) {
                         for ($j = 0; $j < count($roomItems); $j++) {
                             if ($arrComments[$i]['room_item_id'] == $roomItems[$j]['itemId']) {
                                 $arrComments[$i]['comment'] = str_replace("\"", "'", $arrComments[$i]['comment']);
                                 $arrComments[$i][1] = str_replace("\"", "'", $arrComments[$i][1]);
                                 $roomItems[$j]['comments'][] = $arrComments[$i];
                             }
                         }
                     }
                 }
                 //GET THE LAST ITEM IMAGE
                 $commentsSql = "SELECT\n\t\t\t\t\t\t\t\t\t\t image_name\n\t\t\t\t\t\t\t\t\t\t,date AS imageUploadDate\n\t\t\t\t\t\t\t\t\t\t,room_item_id\n\t\t\t\t\t\t\t\t\t\t,`order`\n\t\t\t\t\t\t\t\t\tFROM report_images\n\t\t\t\t\t\t\t\t\tWHERE room_item_id IN(" . $itemIdString . ")\n\t\t\t\t\t\t\t\t\tORDER BY `order`";
                 $arrComments = $dynamo->customFetchQuery($commentsSql);
                 if (count($arrComments) > 0) {
                     for ($i = 0; $i < count($arrComments); $i++) {
                         for ($j = 0; $j < count($roomItems); $j++) {
                             if ($arrComments[$i]['room_item_id'] == $roomItems[$j]['itemId']) {
                                 $roomItems[$j]['images'][$arrComments[$i]['order']][] = $arrComments[$i];
                             }
                         }
                     }
                 }
                 $roomNameArray = array();
                 for ($i = 0; $i < count($roomItems); $i++) {
                     for ($j = 0; $j < count($rooms); $j++) {
                         if ($rooms[$j]['roomId'] == $roomItems[$i]['room_id']) {
                             $roomNameArray[] = $rooms[$j]['roomName'];
                         }
                     }
                 }
                 if (count($roomNameArray) > 0) {
                     $roomNameString = "\"" . implode("\",\"", $roomNameArray) . "\"";
                     //GET ALL THE COMMENTS PER ITEM
                     $commentsSql = "SELECT\n\t\t\t\t\t\t\t\t\t\t c.id AS itemId\n\t\t\t\t\t\t\t\t\t\t ,i.id AS roomItemId\n\t\t\t\t\t\t\t\t\t\t,i.name AS itemName\n\t\t\t\t\t\t\t\t\t\t,c.comment AS comment\n\t\t\t\t\t\t\t\t\t\t,c.order AS `order`\n\t\t\t\t\t\t\t\t\t\t,c.date AS commentDate\n\t\t\t\t\t\t\t\t\t\t,u.first_name AS firstName\n\t\t\t\t\t\t\t\t\t\t,u.last_name AS lastName\n\t\t\t\t\t\t\t\t\t\t,i.room_template_item_id AS room_template_item_id\n\t\t\t\t\t\t\t\t\t\t,rm.name AS room_name\n\t\t\t\t\t\t\t\t\tFROM report_room_item_comments c\n\t\t\t\t\t\t\t\t\t\t  INNER JOIN report_room_items i ON i.id = c.room_item_id\n\t\t\t\t\t\t\t\t\t\t  INNER JOIN report_rooms rm ON rm.id = i.room_id\n\t\t\t\t\t\t\t\t\t\t  INNER JOIN reports r ON r.id = rm.report_id\n\t\t\t\t\t\t\t\t\t\t  INNER JOIN users u ON u.id = c.user_id\n\t\t\t\t\t\t\t\t\tWHERE r.property_id = " . $propertyId . "\n\t\t\t\t\t\t\t\t\t  AND i.room_template_item_id IN( " . implode(",", $arrayTemplateId) . ")\n\t\t\t\t\t\t\t\t\t  AND r.is_submitted = 1\n\t\t\t\t\t\t\t\t\t  AND i.name IN(" . $itemNameString . ")\n\t\t\t\t\t\t\t\t\t  AND rm.name IN(" . $roomNameString . ") \n\t\t\t\t\t\t\t\t\t  ORDER BY c.order";
                     $arrComments = $dynamo->customFetchQuery($commentsSql);
                     if (count($arrComments) > 0) {
                         for ($i = 0; $i < count($arrComments); $i++) {
                             for ($j = 0; $j < count($roomItems); $j++) {
                                 if ($arrComments[$i]['room_template_item_id'] == $roomItems[$j]["itemTemplateId"]) {
                                     $arrComments[$i]['commentDate'] = date('m/d/Y g:ia', strtotime($arrComments[$i]['commentDate']));
                                     $roomItems[$j]['comment_thread'][] = $arrComments[$i];
                                 }
                             }
                         }
                     }
                     $imageSql = "SELECT\n\t\t\t\t\t\t\t\t\t\t\t c.id AS itemId\n\t\t\t\t\t\t\t\t\t\t\t,c.room_item_id AS roomItemId\n\t\t\t\t\t\t\t\t\t\t\t,i.name AS itemName\n\t\t\t\t\t\t\t\t\t\t\t,c.image_name AS imageName\n\t\t\t\t\t\t\t\t\t\t\t,c.order AS `order`\n\t\t\t\t\t\t\t\t\t\t\t,c.date\n\t\t\t\t\t\t\t\t\t\t\t,u.first_name AS firstName\n\t\t\t\t\t\t\t\t\t\t\t,u.last_name AS lastName\n\t\t\t\t\t\t\t\t\t\t\t,i.room_template_item_id AS room_template_item_id\n\t\t\t\t\t\t\t\t\t\t\t,rm.name AS room_name\n\t\t\t\t\t\t\t\t\t\tFROM report_images c\n\t\t\t\t\t\t\t\t\t\t\t  INNER JOIN report_room_items i ON i.id = c.room_item_id\n\t\t\t\t\t\t\t\t\t\t\t  INNER JOIN report_rooms rm ON rm.id = i.room_id\n\t\t\t\t\t\t\t\t\t\t\t  INNER JOIN reports r ON r.id = rm.report_id\n\t\t\t\t\t\t\t\t\t\t\t  INNER JOIN users u ON u.id = c.user_id\n\t\t\t\t\t\t\t\t\t\tWHERE r.property_id = " . $propertyId . "\n\t\t\t\t\t\t\t\t\t\t  AND i.room_template_item_id IN( " . implode(",", $arrayTemplateId) . ")\n\t\t\t\t\t\t\t\t\t\t  AND r.is_submitted = 1\n\t\t\t\t\t\t\t\t\t\t  AND i.name IN(" . $itemNameString . ")\n\t\t\t\t\t\t\t\t\t\t  AND rm.name IN(" . $roomNameString . ")\n\t\t\t\t\t\t\t\t\t\t  ORDER BY c.order";
                     $arrComments = $dynamo->customFetchQuery($imageSql);
                     if (count($arrComments) > 0) {
                         for ($i = 0; $i < count($arrComments); $i++) {
                             for ($j = 0; $j < count($roomItems); $j++) {
                                 if ($arrComments[$i]['room_template_item_id'] == $roomItems[$j]["itemTemplateId"]) {
                                     $arrComments[$i]['imageUploadDate'] = date('m/d/Y g:ia', strtotime($arrComments[$i]['date']));
                                     $roomItems[$j]['image_thread'][] = $arrComments[$i];
                                 }
                             }
                         }
                     }
                 }
                 for ($i = 0; $i < count($roomItems); $i++) {
                     for ($j = 0; $j < count($rooms); $j++) {
                         if ($rooms[$j]['roomId'] == $roomItems[$i]['room_id']) {
                             if (!$roomItems[$i]['arrayRoomItemsUnits']) {
                                 $roomItems[$i]['arrayRoomItemsUnits'] = array();
                             }
                             if (!$roomItems[$i]['comments']) {
                                 $roomItems[$i]['comments'] = array();
                             }
                             if (!$roomItems[$i]['images']) {
                                 $roomItems[$i]['images'] = array();
                             }
                             if (!$roomItems[$i]['comment_thread']) {
                                 $roomItems[$i]['comment_thread'] = array();
                             }
                             if (!$roomItems[$i]['image_thread']) {
                                 $roomItems[$i]['image_thread'] = array();
                             }
                             $rooms[$j]['items'][] = $roomItems[$i];
                         }
                     }
                 }
             }
             $data['rooms'] = $rooms;
         }
         //GET REPORT COMMENTS
         $sqlReportComment = "SELECT\t\n\t\t\t\t\t\t\t\t\t  report_comments.id,\n\t\t\t\t\t\t\t\t\t  report_comments.comment,\n\t\t\t\t\t\t\t\t\t  users.first_name,\n\t\t\t\t\t\t\t\t\t  users.last_name,\n\t\t\t\t\t\t\t\t\t  report_comments.date,\n\t\t\t\t\t\t\t\t\t  reports.is_submitted,\n\t\t\t\t\t\t\t\t\t  reports.is_saved\n\t\t\t\t\t\t\t\tFROM report_comments\n\t\t\t\t\t\t\t\t\t INNER JOIN users ON users.id = report_comments.user_id\n\t\t\t\t\t\t\t\t\t INNER JOIN reports ON reports.id = report_comments.report_id\n\t\t\t\t\t\t\t\tWHERE report_comments.property_id=?\n\t\t\t\t\t\t\t\t";
         $arrReportComments = array();
         if ($reportCommentStmt = $mysqli->prepare($sqlReportComment)) {
             $reportCommentStmt->bind_param("i", $propertyId);
             if ($reportCommentStmt->execute()) {
                 $reportCommentStmt->bind_result($reportCommentId, $reportComment, $reportCommentFirstName, $reportCommentLastName, $reportCommentDate, $reportIsSubmitted, $reportIsSaved);
                 $reportCommentStmt->store_result();
                 $reportCommentsCtr = 0;
                 while ($reportCommentStmt->fetch()) {
                     $arrReportComments[$reportCommentsCtr] = array('id' => $reportCommentId, 'comment' => $reportComment, 'user' => $reportCommentFirstName . ' ' . $reportCommentLastName, 'date' => date('m/d/Y g:ia', strtotime($reportCommentDate)), 'isSubmitted' => $reportIsSubmitted, 'isSaved' => $reportIsSaved);
                     $reportCommentsCtr++;
                 }
                 $reportCommentStmt->free_result();
                 $reportCommentStmt->close();
             }
         }
         $data['reportComments'] = $arrReportComments;
         //REPORT
         $reportDateSql = "SELECT date_reported FROM reports WHERE property_id=? ORDER BY date_reported ASC LIMIT 1";
         if ($reportDateStmt = $mysqli->prepare($reportDateSql)) {
             $reportDateStmt->bind_param("i", $propertyId);
             if ($reportDateStmt->execute()) {
                 $reportDateStmt->bind_result($reportFirstDate);
                 $reportDateStmt->store_result();
                 $reportDateStmt->fetch();
                 $data['firstReportDate'] = $reportFirstDate;
                 $reportDateStmt->free_result();
                 $reportDateStmt->close();
             }
         }
         $result['success'] = true;
         $result['data'] = $data;
     } else {
         $result['message'] = "Sorry, there has been a problem processing your request.";
     }
     $mysqli->close();
     if ($isJson) {
         header('Content-type: application/json');
         echo json_encode($result);
     } else {
         return $data;
     }
 }
Beispiel #3
0
 if (trim($estimatesArray["property_id"]) != '') {
     $properties_obj = new Dynamo("properties");
     $propertyArray = $properties_obj->getAll("WHERE id = " . $propertyId);
     $propertyArray = $propertyArray[0];
     $estimates_multiplier = $propertyArray['estimates_multiplier'];
     if (!isset($estimates_multiplier) || $estimates_multiplier == 0 || $estimates_multiplier < 0) {
         $estimates_multiplier = 1;
     }
     $estimate_room_items_units_obj = new Dynamo("estimate_room_items_units");
     $query = "SELECT eu.estimate_id,eu.units,er.room_template_id,eu.scope,re.item_name,(eu.price_per_unit*{$estimates_multiplier}) AS price_per_unit,re.unit_of_measure,eri.name,er.name AS estimate_room_name,(eu.units *  eu.price_per_unit * {$estimates_multiplier}) AS total_cost\n\t\tFROM estimate_room_items_units eu \n\t\tINNER JOIN work_category_estimates re ON eu.work_category_estimates_id = re.id\n\t\tINNER JOIN estimate_room_items eri ON eri.id = eu.estimate_room_items_id\n\t\tINNER JOIN estimate_rooms er ON eri.room_id = er.id\n\t\tWHERE eu.estimate_id = " . $estimatesId . " AND eu.units != 0 ORDER BY er.room_template_id,eu.estimate_room_items_id,er.name";
     $estimate_room_items_units_array = $estimate_room_items_units_obj->customFetchQuery($query);
     $estimatesEmailBody = "<table border='1' bordercolor='#D0D7E5' style='border:1px solid #D0D7E5;color:#fff;' cellpadding='0' cellspacing='0'>";
     $email_sub_body = '';
     $cost = 0;
     $total_cost = 0;
     $unitsObj = new Dynamo("units");
     $unitsArray = $unitsObj->getAllWithId();
     for ($i = 0; $i < count($estimate_room_items_units_array); $i++) {
         if ($unitsArray[$estimate_room_items_units_array[$i]['unit_of_measure']]) {
             $unit_of_measure = $unitsArray[$estimate_room_items_units_array[$i]['unit_of_measure']]['estimate_unit'];
         }
         $email_sub_body .= "<tr>\n\t\t\t\t<td style='text-align:left;font:normal  Arial;color:#fff'>&nbsp;&nbsp;" . $estimate_room_items_units_array[$i]['name'] . " - <em>" . $estimate_room_items_units_array[$i]['item_name'] . "</em>&nbsp;&nbsp;</td>\n\t\t\t\t<td style='text-align:right;font:normal  Arial;color:#fff'>&nbsp;&nbsp;" . $estimate_room_items_units_array[$i]['units'] . " " . $unit_of_measure . "&nbsp;&nbsp;</td>\n\t\t\t\t<td style='text-align:right;font:normal  Arial;color:#fff'>&nbsp;&nbsp;@ \$" . number_format(number_format($estimate_room_items_units_array[$i]['price_per_unit'], 2, '.', ''), 2) . "&nbsp;&nbsp;</td>\n\t\t\t\t<td style='text-align:right;font:normal  Arial;color:#fff'>&nbsp;&nbsp;\$" . number_format(number_format($estimate_room_items_units_array[$i]['total_cost'], 2, '.', ''), 2) . "&nbsp;&nbsp;</td>\n\t\t\t</tr>";
         if (trim($estimate_room_items_units_array[$i]['scope']) != '') {
             $email_sub_body .= "<tr>\n\t\t\t\t<td style='text-align:left;font:normal  Arial;color:#fff;padding:5px;' colspan='4'><strong> - Scope:</strong> " . str_replace("\n", "<br />", $estimate_room_items_units_array[$i]['scope']) . "</td>\n\t\t\t</tr>";
         }
         $cost += $estimate_room_items_units_array[$i]['total_cost'];
         if ($estimate_room_items_units_array[$i]['room_template_id'] != $estimate_room_items_units_array[$i + 1]['room_template_id'] || $estimate_room_items_units_array[$i]['estimate_room_name'] != $estimate_room_items_units_array[$i + 1]['estimate_room_name'] || !$estimate_room_items_units_array[$i + 1]['room_template_id']) {
             $estimatesEmailBody .= "<tr>\n\t\t\t\t\t<td colspan='3' style='text-align:left;font:bold  Arial;color:#fff;'>&nbsp;&nbsp;<strong>" . $estimate_room_items_units_array[$i]['estimate_room_name'] . "<strong>&nbsp;&nbsp;</td>\n\t\t\t\t\t<td style='text-align:right;font:normal  Arial;color:#fff;'>&nbsp;&nbsp;\$" . number_format(number_format($cost, 2, '.', ''), 2) . "&nbsp;&nbsp;</td>\n\t\t\t\t</tr>";
             $estimatesEmailBody .= $email_sub_body;
             $total_cost += $cost;
             if ($i == count($estimate_room_items_units_array) - 1) {
Beispiel #4
0
define('__BASENAME__', basename(__ROOT__));
require_once __ROOT__ . '/modules/Dynamo.class.php';
$result['success'] = false;
$result['message'] = '';
$propertyId = isset($_POST['propertyId']) ? $_POST['propertyId'] : 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
Beispiel #5
0
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/modules/Property.class.php';
require_once dirname(dirname(dirname(__FILE__))) . '/modules/Dynamo.class.php';
$propertyObj = new Property();
$listProperties = array();
if ($propertyObj) {
    $listProperties = $propertyObj->getArchivedProperties(false);
}
$report_images = new Dynamo("report_images");
$array_property_images = $report_images->getAll("WHERE property_image = 1");
if (count($array_property_images) > 0) {
    $array_property_images2 = array();
    for ($i = 0; $i < count($array_property_images); $i++) {
        $array_property_images2[$array_property_images[$i]['property_id']] = $array_property_images[$i];
    }
    $array_property_images = $array_property_images2;
}
?>

<div class="pull-left"><h4>Archived Properties</h4></div>
<div class="pull-right">
	<form id="searchPropertyForm" method="POST" onsubmit="return false">
		<input type="text" name="searchProperties" id="searchProperties" class="input-large search-query" placeholder="Search Archived Properties" />
        <div id="loading_search_archives_image"><img src="images/loading.gif" /></div><div class="clearfix"></div>
		<input type="hidden" id="baseName" name="baseName" value="<?php 
echo __BASENAME__;
?>
" />
	</form>
</div>
<?php

require_once dirname(dirname(__FILE__)) . '/modules/Dynamo.class.php';
$result['success'] = false;
$result['message'] = '';
$report_room_items = new Dynamo("report_room_items");
if (trim($_REQUEST['roomId']) != '') {
    $arrayRoomItemsId = $report_room_items->customFetchQuery("SELECT id FROM report_room_items WHERE room_id = " . $_REQUEST['roomId'] . " AND status_id = 2");
    $report_room_items->customExecuteQuery("UPDATE report_room_items SET status_id = 1 WHERE room_id = " . $_REQUEST['roomId'] . " AND status_id = 2");
    if (count($arrayRoomItemsId) > 0) {
        $arrayRoomItemsId2 = array();
        for ($i = 0; $i < count($arrayRoomItemsId); $i++) {
            $arrayRoomItemsId2[] = $arrayRoomItemsId[$i]['id'];
        }
        $result['success'] = true;
        $result['message'] = $arrayRoomItemsId2;
    } else {
        $result['success'] = false;
        $result['message'] = "All pending items have already been marked as complete";
    }
} else {
    $result['success'] = false;
    $result['message'] = "Oops, there's a problem with these line items";
}
header('Content-type: application/json');
echo json_encode($result);
Beispiel #7
0
<?php

if (!isset($_SESSION)) {
    session_start();
}
define('__ROOT__', dirname(dirname(__FILE__)));
define('__BASENAME__', basename(__ROOT__));
require_once __ROOT__ . '/modules/Dynamo.class.php';
$community_properties_object = new Dynamo("community_properties");
$community_reports_object = new Dynamo("community_reports");
$community_report_rooms_object = new Dynamo("community_report_rooms");
$community_report_room_items_object = new Dynamo("community_report_room_items");
$community_report_room_item_comments = new Dynamo("community_report_room_item_comments");
$result['success'] = false;
$result['message'] = '';
if (trim($_REQUEST['community']) != '' && trim($_REQUEST['jobType']) != '' && trim($_REQUEST['propertyType']) != '' && trim($_REQUEST['city']) != '' && trim($_REQUEST['zip']) != '' && trim($_REQUEST['emails']) != '' && trim($_REQUEST['id']) != '') {
    $_REQUEST['state'] = null;
    $_REQUEST['property_type'] = $_REQUEST['propertyType'];
    $_REQUEST['job_type'] = $_REQUEST['jobType'];
    $_REQUEST['created_by'] = $_REQUEST['userId'];
    $_REQUEST['emails'] = $_REQUEST['emails'];
    $community_properties_array = $community_properties_object->getOne();
    $_REQUEST['date_created'] = $community_properties_array["date_created"];
    if ($community_properties_object->edit()) {
        $result['success'] = true;
        $result['message'] = 'Community successfully edited!';
        if (trim($_REQUEST['data']) != '') {
            $_REQUEST['property_id'] = $_REQUEST['id'];
            $_REQUEST['date_reported'] = date("Y-m-d H:i:s", time());
            $_REQUEST['status_id'] = 0;
            $_REQUEST['user_id'] = $_REQUEST['created_by'] = $_REQUEST['reported_by'] = $_REQUEST['userId'];
 $complex_reports_obj = new Dynamo("complex_reports");
 $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) != '') {
<?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);
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/modules/Dynamo.class.php';
$sub_contractors = new Dynamo("sub_contractors");
$work_categories = new Dynamo("work_categories");
if ($_SESSION['user_type'] == 5) {
    $readonly = true;
} else {
    $readonly = false;
}
$work_categories_array = $work_categories->getAll("WHERE parent_id = 0");
$sub_contractor_work_category = new Dynamo("sub_contractor_work_category");
if (trim($_REQUEST['id']) != '') {
    $array_sub_contractor = $sub_contractors->getOne();
    if (count($array_sub_contractor) > 0) {
        $array_sub_work = $sub_contractor_work_category->getAllWithId_default("WHERE sub_contractor_id = " . $_REQUEST['id'], "work_category_id");
        ?>
	
		<form method="POST" class="form-horizontal" id="addSubContractorForm" onSubmit="return false;">
		<input type="hidden" id="baseName" name="baseName" value="<?php 
        echo __BASENAME__;
        ?>
" />
		<input type="hidden" id="id" name="id" value="<?php 
        print $_REQUEST['id'];
        ?>
" />
		<div class="pull-left"><h4>View SubContractor</h4></div>
		<div class="pull-right"><button class="btn btn-warning" type="submit">Submit Changes</button> &nbsp;<?php 
        if ($_SESSION['user_type'] != 5) {
            ?>
<?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'] = '';
$id = !isset($_POST['id']) ? "" : $_POST['id'];
if (trim($id) != '') {
    $estimate_rooms = new Dynamo("estimate_rooms");
    $estimate_room_items_units = new Dynamo("estimate_room_items_units");
    if ($estimate_rooms->deleteCustom("WHERE id = " . $id)) {
        $query = "DELETE FROM estimate_room_items_units WHERE estimate_room_items_id IN (SELECT id FROM estimate_room_items WHERE room_id = " . $id . ")";
        $estimate_room_items_units->customExecuteQuery($query);
        $estimate_room_items = new Dynamo("estimate_room_items");
        if ($estimate_room_items->deleteCustom("WHERE room_id = " . $id)) {
            $result['success'] = true;
            $result['message'] = 'Room successfully deleted.';
        }
    }
}
header('Content-type: application/json');
echo json_encode($result);
Beispiel #12
0
}
exit;*/
$roomObj = new Room();
$listRoomTemplates = $roomObj->getRoomTemplates(false);
$reportObj = new Report();
if ($propertyId != 0) {
    $propertyObj = new Property();
    $propertyInfo = $propertyObj->getPropertyInfo($propertyId, false);
    if (!$propertyInfo) {
        echo "No property found.";
        return;
    }
    $reportId = $reportObj->getPreviousReportId($propertyId, false);
    $reportInfo = $reportObj->getReportDetails($reportId, false);
}
$complex_properties_obj = new Dynamo("complex_properties");
$complex_properties_array = $complex_properties_obj->getAll("ORDER BY id");
?>
<div id="community_left">
	<form method="POST" class="form-horizontal" id="addPropertyForm" onsubmit="return false;">
	<input type="hidden" id="baseName" name="baseName" value="<?php 
echo __BASENAME__;
?>
" />
	<input type="hidden" id="userId" name="userId" value="<?php 
echo $_SESSION['user_id'];
?>
" />
		<div class="pull-left"><h4>Add Community</h4></div>
		<div class="clearfix"></div>
Beispiel #13
0
 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");
     $room_template_items_obj = new Dynamo("room_template_items");
     //get previous room item units
     if (!$copy_from_report) {
         $estimate_room_items_units_array = $estimate_room_items_units_obj->getAll("WHERE estimate_id = " . $estimatesId);
     }
     $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;
Beispiel #14
0
<?php

if (!isset($_SESSION)) {
    session_start();
}
define('__ROOT__', dirname(dirname(__FILE__)));
define('__BASENAME__', basename(__ROOT__));
$result['success'] = false;
$result['message'] = '';
require_once __ROOT__ . '/modules/Dynamo.class.php';
if (trim($_REQUEST['estimate_unit']) != '') {
    $unitsObj = new Dynamo("units");
    if ($unitsObj->add()) {
        $result['success'] = true;
        $result['message'] = 'Units successfully added!';
    } 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.';
}
header('Content-type: application/json');
echo json_encode($result);
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/modules/Dynamo.class.php';
if (trim($_REQUEST['id']) != '') {
    $work_categories = new Dynamo("work_categories");
    $work_category = $work_categories->getOne();
    $parent_work_categories = $work_categories->getAll("WHERE parent_id = 0");
    if (count($work_category) > 0) {
        ?>
		<form method="POST" class="form-horizontal" id="workCategoryForm">
		<input type="hidden" id="baseName" name="baseName" value="<?php 
        echo __BASENAME__;
        ?>
" />
		<input type="hidden" id="id" name="id" value="<?php 
        print $work_category['id'];
        ?>
" />
		<input type="hidden" id="date_created" name="date_created" value="<?php 
        print $work_category['date_created'];
        ?>
" />
		<div class="pull-left"><h4>Edit Work Category</h4></div>
		<div class="pull-right"><button class="btn btn-warning" type="submit">Submit Changes</button> &nbsp; <a href="work_categories.html" class="btn btn-default">Cancel</a></div>
		<div class="clearfix"></div>
		
		<div id="status-message"></div>
		<?php 
        if (count($parent_work_categories) > 0) {
            ?>
        <div class="control-group">
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/modules/Dynamo.class.php';
$dailyLogsObject = new Dynamo("daily_logs");
$propertiesObject = new Dynamo("properties");
$daily_logs_today_progress_object = new Dynamo("daily_logs_today_progress");
$daily_logs_images_object = new Dynamo("daily_logs_images");
if (trim($_REQUEST['estimate']) == "true") {
    $estimate = "&estimate=true";
} else {
    $estimate = "";
}
if (trim($_REQUEST["id"]) != '') {
    $_REQUEST["daily_logs_id"] = $_REQUEST["id"];
    $daily_logs_array = $dailyLogsObject->getOne();
} else {
    header("Location: add_daily_log.html?propertyId=" . $_REQUEST["propertyId"] . $estimate);
    exit;
}
if (trim($_REQUEST["propertyId"]) != '') {
    $_REQUEST['id'] = $_REQUEST["propertyId"];
    $propertyArray = $propertiesObject->getOne();
} else {
    print "You'll need property ID in order to proceed";
    exit;
}
?>
	<form method="POST" class="form-horizontal" id="addDailyLog">
	<input type="hidden" id="baseName" name="baseName" value="<?php 
echo __BASENAME__;
?>
     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;
         }
     }
     $estimate_room_id += 1;
 }
 if (trim($query) != '') {
     $query = substr($query, 0, -1);
     $estimatesObj->customExecuteQuery($query);
 }
 $estimate_room_items = new Dynamo("estimate_room_items");
 $count = 0;
 $query = '';
 for ($j = 0; $j < count($community_report_room_items_array); $j++) {
     if ($j == 0 || $count == 0) {
         if (trim($query) != '') {
             $query = substr($query, 0, -1);
             $estimate_room_items->customExecuteQuery($query);
         }
         $query = "INSERT INTO estimate_room_items (`estimate_id`,`room_id`,`room_template_item_id`,`name`,`date_created`) VALUES";
     }
     $query .= "({$estimateId}," . $community_report_room_items_array[$j]['room_id'] . "," . $community_report_room_items_array[$j]['room_template_item_id'] . ",\"" . $community_report_room_items_array[$j]['name'] . "\",NOW()),";
     if ($j == count($community_report_room_items_array) - 1) {
         $query = substr($query, 0, -1);
         $estimate_room_items->customExecuteQuery($query);
     }
Beispiel #18
0
<?php

if (!isset($_SESSION)) {
    session_start();
}
define('__ROOT__', dirname(dirname(__FILE__)));
define('__BASENAME__', basename(__ROOT__));
$result['success'] = false;
$result['message'] = '';
require_once __ROOT__ . '/modules/Dynamo.class.php';
if (trim($_REQUEST['estimate_unit']) != '' && trim($_REQUEST['id']) != '') {
    $unitsObj = new Dynamo("units");
    if ($unitsObj->edit()) {
        $result['success'] = true;
        $result['message'] = 'Estimate Unit successfully edited!';
    } 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.';
}
header('Content-type: application/json');
echo json_encode($result);
Beispiel #19
0
    ?>
 - Edit Estimate</h4></div>
	<div class="pull-right"><a href="edit_property_estimate.html?propertyId=<?php 
    echo $propertyId;
    ?>
" class="btn btn-small btn-warning"><i class="icon-info-sign icon-white"></i> Property Details</a></div>
	<div class="clearfix"></div>
	<div id="status-message"></div>
    
	<div id="addReportStatus"></div>
	
	<div id="rooms-wrapper" class="accordion">
		<?php 
    $tmpRoomIndex = 0;
    if (count($estimatesInfo['rooms']) > 0) {
        $units = new Dynamo("units");
        $arrayUnits = $units->getAllWithId();
        foreach ($estimatesInfo['rooms'] as $room) {
            // var_dump($room);
            ?>
				<div class="accordion-group" id="room_<?php 
            echo $tmpRoomIndex;
            ?>
">
					<div class="accordion-heading">
						<div class="row-fluid">
							<div class="room-name">
								<a href="#collapse_<?php 
            echo $tmpRoomIndex;
            ?>
" data-parent="#rooms-wrapper" data-toggle="collapse" class="accordion-toggle"><?php 
Beispiel #20
0
<?php

if (!isset($_SESSION)) {
    session_start();
}
if (trim($_SESSION['user_id']) == '') {
    exit;
}
define('__ROOT__', dirname(dirname(__FILE__)));
define('__BASENAME__', basename(__ROOT__));
$result['success'] = '';
require_once __ROOT__ . '/modules/Dynamo.class.php';
if (trim($_REQUEST["unit_id"]) != '') {
    $estimate_room_items_units_obj = new Dynamo("estimate_room_items_units");
    $query = "DELETE FROM estimate_room_items_units WHERE id = " . $_REQUEST["unit_id"];
    if ($estimate_room_items_units_obj->customExecuteQuery($query)) {
        $result['success'] = true;
    }
}
if (trim($result['success']) == '') {
    $result['success'] = false;
}
header('Content-type: application/json');
echo json_encode($result);
define('__ROOT__', dirname(dirname(__FILE__)));
define('__BASENAME__', basename(__ROOT__));
require_once __ROOT__ . '/modules/Dynamo.class.php';
require_once __ROOT__ . '/config/main.config.php';
$_REQUEST = $_POST;
if (trim($_REQUEST['email']) != '' && trim($_REQUEST['first_name']) != '' && trim($_REQUEST['last_name']) != '' && trim($_REQUEST['phone_number']) != '' && trim($_REQUEST['id']) != '') {
    if (!preg_match(EMAIL_PATTERN, $_REQUEST['email'])) {
        $result['success'] = false;
        $result['message'] = 'Please enter a valid email address.';
    } else {
        if ($_REQUEST['password'] != $_REQUEST['passwordConfirm']) {
            $result['success'] = false;
            $result['message'] = 'Your passwords do not match.';
        } else {
            $subContractorObj = new Dynamo("sub_contractors");
            $sub_contractor_work_category = new Dynamo("sub_contractor_work_category");
            $sub_contractor_id = $_REQUEST['id'];
            $array_sub_categories = $subContractorObj->getOne();
            if (trim($_REQUEST['password']) != '') {
                $password = $_REQUEST['password'];
                $encryptedPass = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5(ENCRYPTION_KEY), $password, MCRYPT_MODE_CBC, md5(md5(ENCRYPTION_KEY))));
                $_REQUEST['password'] = $encryptedPass;
            } else {
                $_REQUEST['password'] = $array_sub_categories['password'];
            }
            if ($subContractorObj->edit()) {
                $sub_contractor_work_category->deleteCustom("WHERE sub_contractor_id = " . $sub_contractor_id);
                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, ",")) {
$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;
        $array_reports_estimates[strtotime($reports[$i]['dateReported'])] = $reports[$i];
    }
    for ($i = 0; $i < count($estimates); $i++) {
        $array_reports_estimates[strtotime($estimates[$i]['dateReported'])] = $estimates[$i];
    }
    for ($i = 0; $i < count($daily_logs); $i++) {
        if ($daily_logs[$i]['closed'] == 1) {
<?php

require_once 'config/main.config.php';
require_once 'modules/Dynamo.class.php';
require_once 'modules/attach_mailer_class.php';
require_once 'mpdf/mpdf60/mpdf.php';
$subcontractor_emails_obj = new Dynamo("subcontractor_emails");
$array_emails = $subcontractor_emails_obj->getAll("WHERE sent = 0");
$users_obj = new Dynamo("users");
$companyAdminArray = $users_obj->getAll("WHERE user_type = 2 AND is_active = 1");
$email_message = '';
for ($i = 0; $i < count($array_emails); $i++) {
    $email_message .= "<h2 style='color:#666;'>Subcontractor Report #" . ($i + 1) . "</h2>";
    $email_message .= $array_emails[$i]['emailBody'];
}
$companyAdminEmails = '';
for ($i = 0; $i < count($companyAdminArray); $i++) {
    $companyAdminEmails .= $companyAdminArray[$i]['email'] . ",";
}
if (trim($email_message) != '' && trim($companyAdminEmails) != '') {
    $companyAdminEmails = substr($companyAdminEmails, 0, -1);
    $host_url = "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname(dirname($_SERVER['PHP_SELF'])), '/\\');
    $pdf_file = "mpdf/pdfs/sub_contractor_report.pdf";
    @unlink($pdf_file);
    @shell_exec("rm -rf " . $pdf_file);
    $emailBody_pdf = str_replace("<img src='{$host_url}", "<img src='", str_replace("<img src='{$host_url}/", "<img src='", str_replace("<img src=\"{$host_url}/", "<img src=\"", $email_message)));
    preg_match_all("/<img src=[\"\\'](.*?)[\"\\']/i", $emailBody_pdf, $array);
    for ($i = 0; $i < count($array[1]); $i++) {
        if (!file_exists($array[1][$i])) {
            $emailBody_pdf = str_replace($array[1][$i], "", $emailBody_pdf);
        }
Beispiel #24
0
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/modules/User.class.php';
require_once dirname(dirname(dirname(__FILE__))) . '/modules/Dynamo.class.php';
if ($_SESSION['user_type'] == 1 && trim($_GET['del']) == 'true' && trim($_GET['id']) != '') {
    $users_obj = new Dynamo("users");
    $query = "DELETE FROM users WHERE id = " . $_GET['id'];
    $users_obj->customExecuteQuery($query);
}
$userObj = new User();
$listUsers = array();
$companyId = isset($_SESSION['company_id']) ? $_SESSION['company_id'] : 0;
if ($userObj) {
    $userRoleId = isset($_SESSION['user_type']) ? $_SESSION['user_type'] : 0;
    if ($userRoleId == 2) {
        $listUsers = $userObj->getAllUsersPerCompany($companyId, false);
    } else {
        $listUsers = $userObj->getAllUsers(false);
    }
}
?>

<div class="pull-left"><h4>Users</h4></div>
<div class="pull-right"><a href="add_user.html" class="btn btn-warning"><i class="icon-plus icon-white"></i> Add User</a></div>
<div class="clearfix"></div>

<div id="status-message"></div>
<table id="userTable" class="common-table">
<tr>
	<th>Username/Email</th>
	<th>Name</th>
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/modules/Report.class.php';
require_once dirname(dirname(dirname(__FILE__))) . '/modules/Dynamo.class.php';
$reportId = isset($_GET['reportId']) ? $_GET['reportId'] : 0;
if ($reportId != 0) {
    $reportObj = new Report();
    $usersObj = new Dynamo("users");
    $array_users = $usersObj->getAllWithId_default(false, "id");
    $subContractorsObj = new Dynamo("sub_contractors");
    $array_sub_contractors = $subContractorsObj->getAllWithId_default(false, "id");
    $reportInfo = $reportObj->getReportDetails($reportId, false, $array_users, $array_sub_contractors);
    $report_images = new Dynamo("report_images");
    $array_report_images_count = $report_images->getAll("WHERE property_id = " . $reportInfo['propertyId']);
    $array_report_images = $report_images->getAllWithId_default("WHERE property_id = " . $reportInfo['propertyId'], 'room_item_id');
    for ($i = 0; $i < count($array_report_images_count); $i++) {
        $array_report_images[$array_report_images_count[$i]['room_item_id']]['count'] += 1;
        if ($array_report_images_count[$i]['image_name'] != $array_report_images[$array_report_images_count[$i]['room_item_id']]['image_name']) {
            $array_report_images[$array_report_images_count[$i]['room_item_id']]['extra_images'] .= $array_report_images_count[$i]['image_name'] . ",";
        }
    }
    $main_image_array = $report_images->getAll("WHERE property_image = 1 AND property_id = " . $reportInfo['propertyId']);
    if (count($main_image_array) > 0) {
        $main_image_array = $main_image_array[0];
    }
    ?>
	
	<form method="POST" class="form-horizontal" id="addReportForm" onsubmit="return false">
	<input type="hidden" id="_BASENAME" name="baseName" value="<?php 
    echo __BASENAME__;
    ?>
Beispiel #26
0
    }
    if (trim($string_community_report) != '') {
        $string_community_report = substr($string_community_report, 0, -1);
        $query = "DELETE FROM complex_report_rooms WHERE report_id IN ({$string_community_report})";
        $complex_reports_obj->customExecuteQuery($query);
        $query = "DELETE FROM community_report_room_items WHERE report_id IN({$string_community_report})";
        $complex_reports_obj->customExecuteQuery($query);
    }
    $query = "DELETE FROM complex_properties WHERE id = " . $_GET['id'];
    $complex_reports_obj->customExecuteQuery($query);
    $query = "DELETE FROM complex_reports WHERE property_id = " . $_GET['id'];
    $complex_reports_obj->customExecuteQuery($query);
    $query = "DELETE FROM complex_subcontractors_assign WHERE property_id = " . $_GET['id'];
    $complex_reports_obj->customExecuteQuery($query);
}
$complex_properties_object = new Dynamo("complex_properties");
$list_complex_properties = array();
if ($complex_properties_object) {
    $list_complex_properties = $complex_properties_object->getAll();
}
?>

<div class="pull-left"><h4>Complex List</h4></div>
<div class="pull-right"><a href="add_complexes.html" class="btn btn-warning"><i class="icon-plus icon-white"></i> Add Complex</a></div>
<div class="clearfix"></div>

<div id="status-message"></div>
<table class="common-table">
<?php 
if (count($list_complex_properties) > 0) {
    ?>
Beispiel #27
0
			<div class="modal-footer-custom">
				<button class="btn btn-primary">Create Property</button>
				<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
			</div>
		</form>
	</div>
	<?php 
$complex_subcontractors_assign_object = new Dynamo("complex_subcontractors_assign");
$complex_subcontractors_assign_array = $complex_subcontractors_assign_object->getAll("WHERE property_id = " . $_REQUEST['id']);
$community_subcontractors_ids_assign_array = array();
for ($i = 0; $i < count($complex_subcontractors_assign_array); $i++) {
    $community_subcontractors_ids_assign_array[$complex_subcontractors_assign_array[$i]['work_category_id']][] = $complex_subcontractors_assign_array[$i]['sub_contractor_id'];
}
$work_categories_object = new Dynamo("work_categories");
$work_categories_array = $work_categories_object->getAll("ORDER BY id");
$sub_contractors_object = new Dynamo("sub_contractors");
$sub_contractors_array = $sub_contractors_object->getAll("INNER JOIN sub_contractor_work_category ON sub_contractors.id = sub_contractor_work_category.sub_contractor_id ORDER BY sub_contractors.first_name");
$work_sub_contractors_array = array();
for ($i = 0; $i < count($sub_contractors_array); $i++) {
    if (!is_array($community_subcontractors_ids_assign_array[$sub_contractors_array[$i]['work_category_id']])) {
        $community_subcontractors_ids_assign_array[$sub_contractors_array[$i]['work_category_id']] = array();
    }
    if (in_array($sub_contractors_array[$i]['id'], $community_subcontractors_ids_assign_array[$sub_contractors_array[$i]['work_category_id']])) {
        $selected = " checked='checked'";
    } else {
        $selected = "";
    }
    $work_sub_contractors_array[$sub_contractors_array[$i]['work_category_id']] .= "<label style='float:left;width:150px;padding-right:20px;white-space:nowrap'><input type=\"checkbox\" class=\"sub_contractor_id_sub\" name='' value='" . $sub_contractors_array[$i]['id'] . "'" . $selected . " /> " . $sub_contractors_array[$i]['first_name'] . " " . $sub_contractors_array[$i]['last_name'] . "</label>";
}
?>
	
Beispiel #28
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;
<?php

if (!isset($_SESSION)) {
    session_start();
}
define('__ROOT__', dirname(dirname(__FILE__)));
define('__BASENAME__', basename(__ROOT__));
require_once __ROOT__ . '/modules/Dynamo.class.php';
if (trim($_REQUEST['id']) != '') {
    $workCategoryObj = new Dynamo("work_categories");
    $workCategoryObj->delete($id);
    if ($workCategoryObj->delete()) {
        $result['success'] = true;
        $result['message'] = 'Work Category successfully deleted!';
    } 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.';
}
header('Content-type: application/json');
echo json_encode($result);
Beispiel #30
0
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/modules/Dynamo.class.php';
$units = new Dynamo("units");
$unitsArray = array();
if ($units) {
    $unitsArray = $units->getAll();
}
?>
<div class="pull-left"><h4>Units</h4></div>
<div class="pull-right"><a href="add_unit.html" class="btn btn-warning"><i class="icon-plus icon-white"></i> Add Unit</a></div>
<div class="clearfix"></div>

<div id="status-message"></div>

<div class="container">
<?php 
if (count($unitsArray) > 0) {
    foreach ($unitsArray as $unit) {
        $id = $unit['id'];
        $estimate_unit = $unit['estimate_unit'];
        ?>
		<div class="row property-list-row" id="templateRow_<?php 
        echo $id;
        ?>
">
			<div class="pull-left">
				<h2><?php 
        echo stripslashes($estimate_unit);
        ?>
</h2>