Ejemplo n.º 1
0
 public function ajax()
 {
     $Logger = new TransLog();
     $UserModel = new User();
     $Amenities = new Amenities();
     $type = Input::get('type');
     if ($type) {
         switch ($type) {
             case 'packages-list':
                 $pending = DB::table('tbl_packages')->join('tbl_package_group', 'package_id', '=', 'pc_groupid');
                 $dtResult = GlobalController::setDatatable($pending, array('pc_id', 'package_name', 'pc_price'), 'pc_id');
                 $aN = array();
                 $aQ = array();
                 foreach ($dtResult['objResult'] as $aRow) {
                     unset($aN);
                     $aN = array();
                     foreach (json_decode($aRow->pc_itemid) as $aM) {
                         $name = $Amenities->getAmenityByOne($aM->id);
                         array_push($aN, $aM->quantity . " " . $name->am_name);
                     }
                     $data = array($aRow->pc_id, $aRow->pc_name, $aN, number_format($aRow->pc_price, 2), '', '<div class="button-container">' . '<button class="btn-blue-admin btn-view-item" data-id="' . $aRow->pc_id . '">View</button>' . '&nbsp; &nbsp;' . '<button class="btn-blue-admin btn-edit-item" data-id="' . $aRow->pc_id . '">Update</button>' . '</div>');
                     $dtResult['aaData'][] = $data;
                 }
                 unset($dtResult['objResult']);
                 echo json_encode($dtResult);
                 break;
             case 'viewPackage':
                 $id = Input::get('id');
                 $aM = DB::table('tbl_packages')->join('tbl_package_group', 'package_id', '=', 'pc_groupid')->where('pc_id', $id)->first();
                 $a = array();
                 foreach (json_decode($aM->pc_itemid) as $aMm) {
                     $name = $Amenities->getAmenityByOne($aMm->id);
                     $data = array('am_id' => $aMm->id, 'name' => $name->am_name, 'quantity' => $aMm->quantity);
                     array_push($a, $data);
                 }
                 $data = array('pc_id' => $id, 'package_id' => $aM->package_id, 'package_name' => $aM->pc_name, 'package_type' => $aM->package_name, 'amenities' => $a, 'numpax' => $aM->pc_num_pax, 'quantity' => $aM->pc_quantity_perday, 'total_amount' => number_format($aM->pc_price, 2));
                 return Response::json($data);
                 break;
                 //                case 'checkQuantity': {
                 //                    $id = Input::get('id');
                 //                    $quantity = Input::get('field');
                 //                    $result = "";
                 //                    $aM = $Amenities->getAmenityByOne($id);
                 //                          if($quantity > $aM->am_quantity){
                 //                              $result = 'Not enough stock.';
                 //                          }
                 //                          return Response::json( array('result' => $result ));
                 //                                          break;
                 //                }
         }
     }
 }
Ejemplo n.º 2
0
 public function ajax()
 {
     /**@$Logger This for instantiate of new translog.*/
     /**@$SOP This for instantiate of  new sophisticated.*/
     /**@$USER This for instantiate of new user.*/
     /**@$type This for input type.*/
     $Logger = new TransLog();
     $UserModel = new User();
     $type = Input::get('type');
     if ($type) {
         switch ($type) {
             case 'users-list':
                 $pending = $UserModel->getAllUsers();
                 $dtResult = GlobalController::setDatatable($pending, array('id', 'user_fname', 'user_lname', 'user_email', 'user_username', 'user_status', 'user_type'), 'id');
                 foreach ($dtResult['objResult'] as $aRow) {
                     try {
                         $usertype = $UserModel->getUserType($aRow->id);
                         $pro = $usertype->user_type;
                     } catch (Exception $ex) {
                         $pro = 0;
                     }
                     switch ($pro) {
                         case 1:
                             $pro = 'Admin';
                             break;
                         case 2:
                             $pro = 'Default';
                             break;
                     }
                     $data = array($aRow->id, $aRow->user_fname, $aRow->user_lname, $aRow->user_email, $aRow->user_username, $aRow->user_status ? "Active" : "Inactive", $pro, 'Action');
                     $dtResult['aaData'][] = $data;
                 }
                 unset($dtResult['objResult']);
                 echo json_encode($dtResult);
                 break;
         }
     }
 }
Ejemplo n.º 3
0
 public function _initialize()
 {
     parent::_initialize();
     $this->model = M('Spec');
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     parent::__construct();
 }
Ejemplo n.º 5
0
 public function _initialize()
 {
     parent::_initialize();
 }
Ejemplo n.º 6
0
 public function ajax()
 {
     $Logger = new TransLog();
     $UserModel = new User();
     $Amenities = new Amenities();
     $Orders = new Orders();
     $type = Input::get('type');
     if ($type) {
         switch ($type) {
             case 'cancelReservation':
                 $id = Input::get('id');
                 $updateArr = array('status' => 0);
                 $whereArr = array('id' => $id);
                 $data = $this->GlobalModel->updateModel('tbl_reservation', $whereArr, $updateArr);
                 $updateArr = array('order_status' => 0);
                 $whereArr = array('order_id' => $id);
                 $data = $this->GlobalModel->updateModel('tbl_orders', $whereArr, $updateArr);
                 break;
             case 'order-list':
                 $pending = DB::table('tbl_reservation')->join('tbl_orders', 'tbl_orders.order_id', '=', 'tbl_reservation.order_id')->join('tbl_orders_room', 'tbl_orders_room.or_orderid', '=', 'tbl_orders.order_id');
                 $dtResult = GlobalController::setDatatable($pending, array('id', 'pack_name', 'number_of_person', 'date_time_from', 'date_time_to', 'order_datecreated', 'order_status'), 'id');
                 foreach ($dtResult['objResult'] as $aRow) {
                     switch ($aRow->status) {
                         case 0:
                             $status = '<button class="colorBtn2 styleBtn">Cancelled</button>';
                             $status .= '<button class="colorBtn8 styleBtn viewMe" data-id="' . $aRow->id . '" >View</button>';
                             break;
                         case 1:
                             $status = 'In Progress';
                             $status .= '<button class="colorBtn2 styleBtn" data-id="' . $aRow->id . '" id="cancelOrder">Cancel</button>';
                             $status .= '<button class="colorBtn8 styleBtn viewMe" data-id="' . $aRow->id . '" >View</button>';
                             break;
                         case 2:
                             $status = '<button class="colorBtn2 styleBtn">Pending</button>';
                             $status .= '<button class="colorBtn2 styleBtn" data-id="' . $aRow->id . '" id="cancelOrder">Cancel</button>';
                             $status .= '<button class="colorBtn8 styleBtn viewMe" data-id="' . $aRow->id . '" >View</button>';
                             break;
                         case 3:
                             $status = '<button class="colorBtn4 styleBtn">Completed</button>';
                             $status .= '<button class="colorBtn8 styleBtn viewMe" data-id="' . $aRow->id . '" >View</button>';
                             break;
                         case 4:
                             $status = '<button class="colorBtn4 styleBtn">Done</button>';
                             break;
                         default:
                             $status = '';
                     }
                     $data = array($aRow->id, $aRow->pack_name, $aRow->number_of_person, '₱' . number_format($aRow->total_amount, 2), $this->GlobalModel->convertDate($aRow->date_time_from) . " - " . $this->GlobalModel->convertDate($aRow->date_time_to), $this->GlobalModel->convertDate($aRow->order_datecreated), $status);
                     $dtResult['aaData'][] = $data;
                 }
                 unset($dtResult['objResult']);
                 echo json_encode($dtResult);
                 break;
             case 'viewReservation':
                 $id = Input::get('id');
                 $getReserve = DB::table('tbl_reservation')->join('tbl_orders', 'tbl_orders.order_id', '=', 'tbl_reservation.order_id')->where('id', $id)->first();
                 foreach (json_decode($getReserve->pc_itemid) as $aMm) {
                     $name = $Amenities->getAmenityByOne($aMm->id);
                     $data = array('am_id' => $aMm->id, 'name' => $name->am_name, 'quantity' => $aMm->quantity);
                     array_push($a, $name->am_name);
                 }
                 return Response::json(array('reserveId' => $getReserve->id, 'dateTo' => $getReserve->date_time_to, 'dateFrom' => $getReserve->date_time_from, 'amt' => $getReserve->total_amount));
                 break;
         }
     }
 }
Ejemplo n.º 7
0
 public function ajax()
 {
     $Logger = new TransLog();
     $UserModel = new User();
     $type = Input::get('type');
     if ($type) {
         switch ($type) {
             case 'amenities-list':
                 $pending = DB::table('tbl_amenities')->join('tbl_amenities_group', 'ag_id', '=', 'am_group');
                 $dtResult = GlobalController::setDatatable($pending, array('am_id', 'am_name', 'am_quantity', 'am_price', 'ag_groupname'), 'am_id');
                 foreach ($dtResult['objResult'] as $aRow) {
                     $data = array($aRow->am_id, $aRow->am_name, $aRow->am_quantity, $aRow->am_capacity, number_format($aRow->am_price, 2), $aRow->ag_groupname, '', '<div class="button-container">' . '<button class="btn-blue-admin btn-view-item" data-id="' . $aRow->am_id . '">View</button>' . '&nbsp; &nbsp;' . '<button class="btn-blue-admin btn-edit-item" data-id="' . $aRow->am_id . '">Update</button>' . '</div>');
                     $dtResult['aaData'][] = $data;
                 }
                 unset($dtResult['objResult']);
                 echo json_encode($dtResult);
                 break;
             case 'viewItem':
                 $id = Input::get('id');
                 $whereVal = array('am_id' => $id);
                 $item = $this->GlobalModel->getModelRowDetailByWhereClause('tbl_amenities', $whereVal, '');
                 $images = DB::table('tbl_images')->where('image_fieldvalue', $id)->get();
                 $img = array();
                 foreach ($images as $im) {
                     $d = array('image_id' => $im->image_id, 'image_name' => $im->image_name);
                     array_push($img, $d);
                 }
                 $data = array('item_name' => $item->am_name, 'item_desc' => $item->am_description, 'item_quantity' => $item->am_quantity, 'item_price' => $item->am_price, 'item_capacity' => $item->am_capacity, 'item_group' => $this->GlobalModel->getGroupName($item->am_group)->ag_groupname, 'group_id' => $this->GlobalModel->getGroupName($item->am_group)->ag_id, 'image' => $img);
                 return Response::json($data);
                 break;
             case 'deleteImage':
                 if (Input::has('id')) {
                     $id = Input::get('id');
                     $whereVal = array('image_id' => $id);
                     $this->GlobalModel->deleteModel('tbl_images', $whereVal);
                     $this->TransLog->transLogger('Amenity Module', 'Deleted Image', $id);
                 }
                 break;
             case 'validateItemName':
                 $whereVal = array('am_name' => Input::get('item_name'));
                 $itemName = $this->GlobalModel->getModelRowCountByWhereClause('tbl_amenities', $whereVal);
                 $data = 0;
                 if ($itemName > 0) {
                     $data = 1;
                 }
                 return Response::json(array('result' => $data));
                 break;
         }
     }
 }
Ejemplo n.º 8
0
 public function ajax()
 {
     $Logger = new TransLog();
     $UserModel = new User();
     $type = Input::get('type');
     if ($type) {
         switch ($type) {
             /** AMENITY TYPE */
             case 'amenitytype-list':
                 $pending = DB::table('tbl_amenities_group');
                 $dtResult = GlobalController::setDatatable($pending, array('ag_id', 'ag_groupname'), 'ag_id');
                 foreach ($dtResult['objResult'] as $aRow) {
                     $data = array($aRow->ag_id, $aRow->ag_groupname, '', '<div class="button-container">' . '<button class="btn-blue-admin btn-edit-item" data-name="' . $aRow->ag_groupname . '" data-id="' . $aRow->ag_id . '">Update</button>' . '</div>');
                     $dtResult['aaData'][] = $data;
                 }
                 unset($dtResult['objResult']);
                 echo json_encode($dtResult);
                 break;
             case 'addAmenityType':
                 if (Input::has('name')) {
                     $insertVal = array('ag_groupname' => Input::get('name'));
                     $this->GlobalModel->insertModel('tbl_amenities_group', $insertVal);
                     $this->TransLog->transLogger('Amenity Module', 'Added Amenity Type', DB::getPdo()->lastInsertId());
                 }
                 break;
             case 'updateAmenityType':
                 if (Input::has('name')) {
                     $updateVal = array('ag_groupname' => Input::get('name'));
                     $whereVal = array('ag_id' => Input::get('id'));
                     $this->GlobalModel->updateModel('tbl_amenities_group', $whereVal, $updateVal);
                     $this->TransLog->transLogger('Amenity Module', 'Updated Amenity Type', Input::get('id'));
                 }
                 break;
             case 'validateTypeName':
                 $whereVal = array('ag_groupname' => Input::get('item_name'));
                 $itemName = $this->GlobalModel->getModelRowCountByWhereClause('tbl_amenities_group', $whereVal);
                 $data = 0;
                 if ($itemName > 0) {
                     $data = 1;
                 }
                 return Response::json(array('result' => $data));
                 break;
                 /** END OF AMENITY TYPE */
                 /** PACKAGE TYPE */
             /** END OF AMENITY TYPE */
             /** PACKAGE TYPE */
             case 'packagetype-list':
                 $pending = DB::table('tbl_package_group');
                 $dtResult = GlobalController::setDatatable($pending, array('package_id', 'package_groupname'), 'package_id');
                 foreach ($dtResult['objResult'] as $aRow) {
                     $data = array($aRow->package_id, $aRow->package_name, '', '<div class="button-container">' . '<button class="btn-blue-admin btn-edit-item" data-name="' . $aRow->package_name . '" data-id="' . $aRow->package_id . '">Update</button>' . '</div>');
                     $dtResult['aaData'][] = $data;
                 }
                 unset($dtResult['objResult']);
                 echo json_encode($dtResult);
                 break;
             case 'reportList':
                 $reportTable = DB::table('tbl_reservation')->where('batch_id', null)->where('status', 3);
                 $dtResult = GlobalController::setDatatable($reportTable, array('id', 'full_name', 'date_time_from', 'date_time_to', 'total_amount'), 'id');
                 foreach ($dtResult['objResult'] as $aRow) {
                     $data = array("<input type='checkbox' name='reportId' id='reportId' value='{$aRow->id}' checked style='visibility: hidden'>", $aRow->id, $aRow->full_name, $aRow->date_time_from, $aRow->date_time_to, "<span>PHP {$aRow->total_amount}</span>");
                     $dtResult['aaData'][] = $data;
                 }
                 unset($dtResult['objResult']);
                 echo json_encode($dtResult);
                 break;
             case 'addPackageType':
                 if (Input::has('name')) {
                     $insertVal = array('package_name' => Input::get('name'));
                     $this->GlobalModel->insertModel('tbl_package_group', $insertVal);
                     $this->TransLog->transLogger('Maintenance Module', 'Added Package Type', DB::getPdo()->lastInsertId());
                 }
                 break;
             case 'updatePackageType':
                 if (Input::has('name')) {
                     $updateVal = array('package_name' => Input::get('name'));
                     $whereVal = array('package_id' => Input::get('id'));
                     $this->GlobalModel->updateModel('tbl_package_group', $whereVal, $updateVal);
                     $this->TransLog->transLogger('Maintenance Module', 'Updated Package Type', Input::get('id'));
                 }
                 break;
             case 'validatePackageTypeName':
                 $whereVal = array('package_name' => Input::get('item_name'));
                 $itemName = $this->GlobalModel->getModelRowCountByWhereClause('tbl_package_group', $whereVal);
                 $data = 0;
                 if ($itemName > 0) {
                     $data = 1;
                 }
                 return Response::json(array('result' => $data));
                 break;
         }
     }
 }
Ejemplo n.º 9
0
    public function ajax()
    {
        $Logger = new TransLog();
        $UserModel = new User();
        $Amenities = new Amenities();
        $Orders = new Orders();
        $type = Input::get('type');
        if ($type) {
            switch ($type) {
                case 'packages-list':
                    $pending = DB::table('tbl_packages')->join('tbl_package_group', 'package_id', '=', 'pc_groupid');
                    $dtResult = GlobalController::setDatatable($pending, array('pc_id', 'package_name', 'pc_price'), 'pc_id');
                    $aN = array();
                    $aQ = array();
                    foreach ($dtResult['objResult'] as $aRow) {
                        unset($aN);
                        $aN = array();
                        foreach (json_decode($aRow->pc_itemid) as $aM) {
                            $name = $Amenities->getAmenityByOne($aM->id);
                            array_push($aN, $aM->quantity . " " . $name->am_name);
                        }
                        $data = array($aRow->pc_id, $aRow->pc_name, $aN, number_format($aRow->pc_price, 2), '', '<div class="button-container">' . '<button class="btn-blue-admin btn-view-item" data-id="' . $aRow->pc_id . '">View</button>' . '&nbsp; &nbsp;' . '<button class="btn-blue-admin btn-edit-item" data-id="' . $aRow->pc_id . '">Update</button>' . '</div>');
                        $dtResult['aaData'][] = $data;
                    }
                    unset($dtResult['objResult']);
                    echo json_encode($dtResult);
                    break;
                case 'viewPackage':
                    $id = Input::get('id');
                    $aM = DB::table('tbl_packages')->join('tbl_package_group', 'package_id', '=', 'pc_groupid')->where('pc_id', $id)->first();
                    $a = array();
                    foreach (json_decode($aM->pc_itemid) as $aMm) {
                        $name = $Amenities->getAmenityByOne($aMm->id);
                        $data = array('am_id' => $aMm->id, 'name' => $name->am_name, 'quantity' => $aMm->quantity);
                        array_push($a, $data);
                    }
                    $data = array('pc_id' => $id, 'package_id' => $aM->package_id, 'package_name' => $aM->pc_name, 'amenities' => $a, 'numpax' => $aM->pc_num_pax, 'total_amount' => number_format($aM->pc_price, 2));
                    return Response::json($data);
                    break;
                case 'accommodation-table':
                    if (Input::get('id') > 0) {
                        $Packages = DB::table('tbl_packages')->join('tbl_package_group', 'package_id', '=', 'pc_groupid')->where('pc_id', Input::get('id'))->get();
                    } else {
                        $Packages = DB::table('tbl_packages')->join('tbl_package_group', 'package_id', '=', 'pc_groupid')->get();
                    }
                    $a = array();
                    $b = array();
                    $c = array();
                    $tbody = '';
                    foreach ($Packages as $pk) {
                        unset($a);
                        $a = array();
                        //                        $Orders = new Orders();
                        //                        $date = Input::get('date') ? Input::get('date') : date('Y-m-d') ;
                        //                        $date2 = Input::get('date_to') ? Input::get('date_to') : date('Y-m-d') ;
                        //                        $rooms = $Orders->getRoomOrder($date, $date2);
                        //                        $order_room = array();
                        //                        foreach($rooms as $room){
                        //                            $data = array(
                        //                                'package_id'    =>  $room->order_packageid,
                        //                                'or_roomid'     =>  json_decode($room->or_roomid)
                        //                            );
                        //                            array_push($order_room, $data);
                        //                        }
                        $tbody .= '<tr>';
                        foreach (json_decode($pk->pc_itemid) as $aMm) {
                            $name = $Amenities->getAmenityByOne($aMm->id);
                            $room = null;
                            if ($name->am_group == 4) {
                                $room = '<br/>(' . $name->am_quantity . ' Left)';
                            }
                            array_push($a, $aMm->quantity . ' ' . $name->am_name . $room);
                        }
                        $tbody .= '
                            <td class="lhs">
                                <a href="#" class="tooltip-ors" style="cursor: pointer;">
                                    <b>' . $pk->pc_name . '</b>
                                    <span>
                                        <img class="callout" src="../img/callout.gif">
                                        <strong>Inclusions</strong><br />
                                        ' . implode("<br/>", $a) . '
                                   </span>
                                </a>
                            </td><td></td>
                                <td style="text-align: center;">' . $pk->pc_num_pax . '</td>
                                ';
                        if (Input::has('date')) {
                            $d = Input::get('date');
                            $day = substr($d, -2);
                        } else {
                            $d = date('Y-m-d');
                            $day = date('d');
                        }
                        $date_today = date('Y-m-d');
                        $datediff = strtotime(Input::get('date_to')) - strtotime($d);
                        $final_date = floor($datediff / (60 * 60 * 24));
                        if ($final_date > 12) {
                            $x = $final_date;
                        } else {
                            $x = 12;
                        }
                        $bookable = 0;
                        unset($b);
                        $b = array();
                        $check = $Orders->getOrderByID($pk->pc_id);
                        $m = 0;
                        if ($x > 18) {
                            $tbody .= '<td></td>';
                            for ($i = 0; $i <= $x; $i++) {
                                $date = date('Y-m-d', strtotime($d . ' +' . $i . ' day'));
                                $availability = "";
                                if (Input::get('pax') > $pk->pc_num_pax) {
                                    $availability = '<td class="max-pax">Max ' . $pk->pc_num_pax . '</td>';
                                    $bookable = 1;
                                } else {
                                    if ($check->count()) {
                                        foreach ($check->get() as $chk) {
                                            if (strtotime($date) >= strtotime(Input::get('date')) && strtotime($date) <= strtotime(Input::get('date_to')) && strtotime(Input::get('date')) <= strtotime(Input::get('date_to')) && strtotime($date) >= strtotime($chk->order_datefrom) && strtotime($date) <= strtotime($chk->order_dateto) && strtotime($chk->order_datefrom) <= strtotime($chk->order_dateto)) {
                                                array_push($b, 1);
                                            }
                                        }
                                    }
                                }
                                if ($m == 0) {
                                    $tbody .= $availability;
                                    $m = 1;
                                }
                            }
                            if (implode(",", $b) > 0) {
                                $tbody .= '<td class="unavailable"">✗</td>';
                                array_push($b, 1);
                            } else {
                                if ($bookable != 1) {
                                    $tbody .= '<td class="available">✓</td>';
                                }
                            }
                            $tbody .= '<td></td>';
                        } else {
                            for ($i = 0; $i <= $x; $i++) {
                                $date = date('Y-m-d', strtotime($d . ' +' . $i . ' day'));
                                $availability = '<td class="available">✓</td>';
                                if ($date_today > Input::get('date')) {
                                    $availability = '<td class="unavailable"">✗</td>';
                                    array_push($b, 1);
                                    $bookable = 1;
                                } else {
                                    if (Input::get('pax') > $pk->pc_num_pax) {
                                        $availability = '<td class="max-pax">Max ' . $pk->pc_num_pax . '</td>';
                                        $bookable = 1;
                                    } else {
                                        if ($check->count() > 0) {
                                            foreach ($check->get() as $chk) {
                                                if (Input::has('date') && Input::has('date_to')) {
                                                    $order_count = $Orders->getSumAllOrders($pk->pc_id, Input::get('date'), Input::get('date_to'));
                                                    if ($pk->pc_quantity_perday <= $order_count) {
                                                        $availability = '<td class="unavailable"">✗</td>';
                                                        array_push($b, 1);
                                                    }
                                                }
                                                if (strtotime($date) >= strtotime($chk->order_datefrom) && strtotime($date) <= strtotime($chk->order_dateto) && strtotime($chk->order_datefrom) <= strtotime($chk->order_dateto)) {
                                                    $availability = '<td class="unavailable"">✗</td>';
                                                    array_push($b, 1);
                                                }
                                                if (strtotime($date) >= strtotime(Input::get('date')) && strtotime($date) <= strtotime(Input::get('date_to')) && strtotime(Input::get('date')) <= strtotime(Input::get('date_to')) && strtotime($date) >= strtotime($chk->order_datefrom) && strtotime($date) <= strtotime($chk->order_dateto) && strtotime($chk->order_datefrom) <= strtotime($chk->order_dateto)) {
                                                    array_push($b, 1);
                                                }
                                            }
                                        } else {
                                            if ($Orders->checkDateAvailability($date, $pk->pc_id) == 1) {
                                                $availability = '<td class="available">✓</td>';
                                            } else {
                                                $availability = '<td class="available">✓</td>';
                                            }
                                        }
                                    }
                                }
                                $tbody .= $availability;
                                $day++;
                            }
                        }
                        $price = number_format($pk->pc_price * ($final_date + 1), 2) < 0 ? $pk->pc_price : number_format($pk->pc_price * ($final_date + 1), 2);
                        if (implode(",", $b) > 0 || Input::has('date_to') && $final_date < 0) {
                            $tB = '<td class="maxGuests button"><a class="bookable notavailable notavailable-bg" title="Not Available"><b class="text notavailable">Date not</b><b class="price notavailable">available</b></a></td>';
                        } else {
                            if (Input::has('id')) {
                                $tB = '<td class="maxGuests button booknow-btn"><a class="bookable booknow bookable-cl" title="Book Now" data-id="' . $pk->pc_id . '"><b class="text">Rebook</b><b class="price">₱' . $price . '</b></a></td>
                                <td class="maxGuests button booknow-btn proceed proceed-' . $pk->pc_id . '"><a class="proceed-payment bookable disabled-payment" title="Proceed" data-id="' . $pk->pc_id . '"><b class="text">Proceed</b><b class="price">payment</b></td>

                                ';
                            } else {
                                $tB = '<td class="maxGuests button booknow-btn"><a class="bookable booknow bookable-cl" title="Book Now" data-id="' . $pk->pc_id . '"><b class="text">Book now</b><b class="price">₱' . $price . '</b></a></td>
                                    <td class="maxGuests button booknow-btn proceed proceed-' . $pk->pc_id . '"><a class="proceed-payment bookable" title="Proceed" data-id="' . $pk->pc_id . '"><b class="text">Proceed</b><b class="price">payment</b></td>

                                    ';
                            }
                        }
                        $tbody .= $bookable == 1 ? '<td class="maxGuests button"><a class="bookable notavailable notavailable-bg" title="Not Available" ><b class="text notavailable">Not</b><b class="price notavailable">Available</b></a></td>' : $tB;
                        $data = array('am_name' => implode(", ", $a), 'package_id' => $pk->package_id, 'package_name' => $pk->pc_name, 'numpax' => $pk->pc_num_pax, 'total_amount' => number_format($pk->pc_price, 2));
                        $tbody .= '</tr>';
                    }
                    $thead = '
                    <th class="tblHeaderGlobal lhs">Package</th>
                    <th class="tblHeaderGlobal"></th>
                    <th class="tblHeaderGlobal maxGuests">MAX GUESTS</th>
                    ';
                    if (Input::has('date')) {
                        $d = Input::get('date');
                        $day = substr($d, -2);
                    } else {
                        $d = date('Y-m-d');
                        $day = date('d');
                    }
                    $datediff = strtotime(Input::get('date_to')) - strtotime($d);
                    $final_date = floor($datediff / (60 * 60 * 24));
                    if ($final_date > 12) {
                        $x = $final_date;
                    } else {
                        $x = 12;
                    }
                    if ($x > 18) {
                        $thead .= '<th class="tblHeaderGlobal selected">
                                    <b class="day">' . strtoupper(substr(date('l', strtotime($d)), 0, 3)) . '</b>
                                <b class="date">' . date('d', strtotime($d)) . '</b>
                                <b class="month">' . strtoupper(date('M', strtotime($d))) . '</b>
                            </th>
                            <th class="tblHeaderGlobal selected"> <b class="date"> >> </b> </th>
                            <th class="tblHeaderGlobal selected">
                                    <b class="day">' . strtoupper(substr(date('l', strtotime(Input::get('date_to'))), 0, 3)) . '</b>
                                <b class="date">' . date('d', strtotime(Input::get('date_to'))) . '</b>
                                <b class="month">' . strtoupper(date('M', strtotime(Input::get('date_to')))) . '</b>
                            </th>
                            ';
                    } else {
                        for ($i = 0; $i <= $x; $i++) {
                            $date = date('Y-m-d', strtotime($d . ' +' . $i . ' day'));
                            $day_ = strtoupper(date('d', strtotime($date)));
                            if (Input::has('date_to') && strtotime($date) <= strtotime(Input::get('date_to'))) {
                                $class = 'selected_day';
                            } else {
                                if (date('N', strtotime($date)) >= 6) {
                                    $class = 'data weekend';
                                } else {
                                    $class = 'selected';
                                }
                            }
                            $thead .= '<th class="tblHeaderGlobal ' . $class . '">
                                        <b class="day">' . strtoupper(substr(date('l', strtotime($date)), 0, 3)) . '</b>
                                    <b class="date">' . $day_ . '</b>
                                    <b class="month">' . strtoupper(date('M', strtotime($date))) . '</b>
                                </th>';
                            $day++;
                        }
                    }
                    $thead .= '<th class="tblHeaderGlobal"></th>';
                    $data = array('date' => $thead, 'packages' => $tbody);
                    return Response::json($data);
                    break;
                case 'accommodation-pertable':
                    $Packages = DB::table('tbl_packages')->join('tbl_package_group', 'package_id', '=', 'pc_groupid')->where('pc_id', Input::get('id'))->get();
                    $a = array();
                    $b = array();
                    $c = array();
                    $tbody = '';
                    foreach ($Packages as $pk) {
                        unset($a);
                        $a = array();
                        $tbody .= '<tr>';
                        foreach (json_decode($pk->pc_itemid) as $aMm) {
                            $name = $Amenities->getAmenityByOne($aMm->id);
                            $data = array('am_id' => $aMm->id, 'name' => $name->am_name, 'quantity' => $aMm->quantity);
                            array_push($a, $name->am_name);
                        }
                        $tbody .= '
                            <td class="lhs">
                                <a href="#" class="tooltip-ors" style="cursor: pointer;">
                                    <b>' . $pk->pc_name . '</b>
                                    <span>
                                        <img class="callout" src="../img/callout.gif">
                                        <strong>Inclusions</strong><br />
                                        ' . implode(", ", $a) . '
                                   </span>
                                </a>
                            </td><td></td>
                                <td style="text-align: center;">' . $pk->pc_num_pax . '</td>
                                ';
                        if (Input::has('date')) {
                            $d = Input::get('date');
                            $day = substr($d, -2);
                        } else {
                            $d = date('Y-m-d');
                            $day = date('d');
                        }
                        $datediff = strtotime(Input::get('date_to')) - strtotime($d);
                        $final_date = floor($datediff / (60 * 60 * 24));
                        if ($final_date > 12) {
                            $x = $final_date;
                        } else {
                            $x = 12;
                        }
                        $bookable = 0;
                        unset($b);
                        $b = array();
                        $check = $Orders->getOrderByID($pk->pc_id);
                        $m = 0;
                        if ($x > 18) {
                            $tbody .= '<td></td>';
                            for ($i = 0; $i <= $x; $i++) {
                                $date = date('Y-m-d', strtotime($d . ' +' . $i . ' day'));
                                $availability = "";
                                if (Input::get('pax') > $pk->pc_num_pax) {
                                    $availability = '<td class="max-pax">Max ' . $pk->pc_num_pax . '</td>';
                                    $bookable = 1;
                                } else {
                                    if ($check) {
                                        if (strtotime($date) >= strtotime(Input::get('date')) && strtotime($date) <= strtotime(Input::get('date_to')) && strtotime(Input::get('date')) <= strtotime(Input::get('date_to')) && strtotime($date) >= strtotime($check->order_datefrom) && strtotime($date) <= strtotime($check->order_dateto) && strtotime($check->order_datefrom) <= strtotime($check->order_dateto)) {
                                            array_push($b, 1);
                                        }
                                    }
                                }
                                if ($m == 0) {
                                    $tbody .= $availability;
                                    $m = 1;
                                }
                            }
                            if (implode(",", $b) > 0) {
                                $tbody .= '<td class="unavailable"">✗</td>';
                                array_push($b, 1);
                            } else {
                                if ($bookable != 1) {
                                    $tbody .= '<td class="available">✓</td>';
                                }
                            }
                            $tbody .= '<td></td>';
                        } else {
                            for ($i = 0; $i <= $x; $i++) {
                                $date = date('Y-m-d', strtotime($d . ' +' . $i . ' day'));
                                $availability = '<td class="available">✓</td>';
                                if (Input::get('pax') > $pk->pc_num_pax) {
                                    $availability = '<td class="max-pax">Max ' . $pk->pc_num_pax . '</td>';
                                    $bookable = 1;
                                } else {
                                    if ($check) {
                                        if (strtotime($date) >= strtotime($check->order_datefrom) && strtotime($date) <= strtotime($check->order_dateto) && strtotime($check->order_datefrom) <= strtotime($check->order_dateto)) {
                                            $availability = '<td class="unavailable"">✗</td>';
                                            array_push($b, 1);
                                        }
                                        if (strtotime($date) >= strtotime(Input::get('date')) && strtotime($date) <= strtotime(Input::get('date_to')) && strtotime(Input::get('date')) <= strtotime(Input::get('date_to')) && strtotime($date) >= strtotime($check->order_datefrom) && strtotime($date) <= strtotime($check->order_dateto) && strtotime($check->order_datefrom) <= strtotime($check->order_dateto)) {
                                            array_push($b, 1);
                                        }
                                    } else {
                                        if ($Orders->checkDateAvailability($date, $pk->pc_id) == 1) {
                                            $availability = '<td class="available">✓</td>';
                                        } else {
                                            $availability = '<td class="available">✓</td>';
                                        }
                                    }
                                }
                                $tbody .= $availability;
                                $day++;
                            }
                        }
                        $price = number_format($pk->pc_price * ($final_date + 1), 2) < 0 ? $pk->pc_price : number_format($pk->pc_price * ($final_date + 1), 2);
                        if (implode(",", $b) > 0 || Input::has('date_to') && $final_date < 0) {
                            $tB = '<td class="maxGuests button"><a class="bookable notavailable notavailable-bg" title="Not Available"><b class="text notavailable">Date not</b><b class="price notavailable">available</b></a></td>';
                        } else {
                            $tB = '<td class="maxGuests button booknow-btn"><a class="bookable" title="Book Now" data-id="' . $pk->pc_id . '"><b class="text">Book now</b><b class="price">₱' . $price . '</b></td>';
                        }
                        $tbody .= $bookable == 1 ? '<td class="maxGuests button"><a class="bookable notavailable notavailable-bg" title="Not Available" ><b class="text notavailable">Not</b><b class="price notavailable">Available</b></a></td>' : $tB;
                        $data = array('am_name' => implode(", ", $a), 'package_id' => $pk->package_id, 'package_name' => $pk->pc_name, 'numpax' => $pk->pc_num_pax, 'total_amount' => number_format($pk->pc_price, 2));
                        $tbody .= '</tr>';
                    }
                    $thead = '
                    <th class="tblHeaderGlobal lhs">Package</th>
                    <th class="tblHeaderGlobal"></th>
                    <th class="tblHeaderGlobal maxGuests">MAX GUESTS</th>
                    ';
                    if (Input::has('date')) {
                        $d = Input::get('date');
                        $day = substr($d, -2);
                    } else {
                        $d = date('Y-m-d');
                        $day = date('d');
                    }
                    $datediff = strtotime(Input::get('date_to')) - strtotime($d);
                    $final_date = floor($datediff / (60 * 60 * 24));
                    if ($final_date > 12) {
                        $x = $final_date;
                    } else {
                        $x = 12;
                    }
                    if ($x > 18) {
                        $thead .= '<th class="tblHeaderGlobal selected">
                                    <b class="day">' . strtoupper(substr(date('l', strtotime($d)), 0, 3)) . '</b>
                                <b class="date">' . date('d', strtotime($d)) . '</b>
                                <b class="month">' . strtoupper(date('M', strtotime($d))) . '</b>
                            </th>
                            <th class="tblHeaderGlobal selected"> <b class="date"> >> </b> </th>
                            <th class="tblHeaderGlobal selected">
                                    <b class="day">' . strtoupper(substr(date('l', strtotime(Input::get('date_to'))), 0, 3)) . '</b>
                                <b class="date">' . date('d', strtotime(Input::get('date_to'))) . '</b>
                                <b class="month">' . strtoupper(date('M', strtotime(Input::get('date_to')))) . '</b>
                            </th>
                            ';
                    } else {
                        for ($i = 0; $i <= $x; $i++) {
                            $date = date('Y-m-d', strtotime($d . ' +' . $i . ' day'));
                            $day_ = strtoupper(date('d', strtotime($date)));
                            if (Input::has('date_to') && strtotime($date) <= strtotime(Input::get('date_to'))) {
                                $class = 'selected_day';
                            } else {
                                if (date('N', strtotime($date)) >= 6) {
                                    $class = 'data weekend';
                                } else {
                                    $class = 'selected';
                                }
                            }
                            $thead .= '<th class="tblHeaderGlobal ' . $class . '">
                                        <b class="day">' . strtoupper(substr(date('l', strtotime($date)), 0, 3)) . '</b>
                                    <b class="date">' . $day_ . '</b>
                                    <b class="month">' . strtoupper(date('M', strtotime($date))) . '</b>
                                </th>';
                            $day++;
                        }
                    }
                    $thead .= '<th class="tblHeaderGlobal"></th>';
                    $data = array('date' => $thead, 'packages' => $tbody);
                    return Response::json($data);
                    break;
                    //                case 'checkQuantity': {
                    //                    $id = Input::get('id');
                    //                    $quantity = Input::get('field');
                    //                    $result = "";
                    //                    $aM = $Amenities->getAmenityByOne($id);
                    //                          if($quantity > $aM->am_quantity){
                    //                              $result = 'Not enough stock.';
                    //                          }
                    //                          return Response::json( array('result' => $result ));
                    //                                          break;
                    //                }
            }
        }
    }
Ejemplo n.º 10
0
 public function ajax()
 {
     $Logger = new TransLog();
     $UserModel = new User();
     $Amenities = new Amenities();
     $Packages = new Packages();
     $type = Input::get('type');
     if ($type) {
         switch ($type) {
             case 'amenities-list':
                 $pending = DB::table('tbl_amenities')->join('tbl_amenities_group', 'ag_id', '=', 'am_group');
                 $dtResult = GlobalController::setDatatable($pending, array('am_id', 'am_name', 'am_quantity', 'am_price', 'ag_groupname'), 'am_id');
                 foreach ($dtResult['objResult'] as $aRow) {
                     $data = array($aRow->am_id, $aRow->am_name, $aRow->am_quantity, $aRow->am_capacity, number_format($aRow->am_price, 2), $aRow->ag_groupname, '', '<div class="button-container">' . '<button class="btn-blue-admin btn-view-item" data-id="' . $aRow->am_id . '">View</button>' . '&nbsp; &nbsp;' . '<button class="btn-blue-admin btn-edit-item" data-id="' . $aRow->am_id . '">Update</button>' . '</div>');
                     $dtResult['aaData'][] = $data;
                 }
                 unset($dtResult['objResult']);
                 echo json_encode($dtResult);
                 break;
             case 'viewItem':
                 $id = Input::get('id');
                 $whereVal = array('am_id' => $id);
                 $item = $this->GlobalModel->getModelRowDetailByWhereClause('tbl_amenities', $whereVal, '');
                 $images = DB::table('tbl_images')->where('image_fieldvalue', $id)->get();
                 $img = array();
                 foreach ($images as $im) {
                     $d = array('image_id' => $im->image_id, 'image_name' => $im->image_name);
                     array_push($img, $d);
                 }
                 $data = array('item_name' => $item->am_name, 'item_desc' => $item->am_description, 'item_quantity' => $item->am_quantity, 'item_price' => $item->am_price, 'item_capacity' => $item->am_capacity, 'item_group' => $this->GlobalModel->getGroupName($item->am_group)->ag_groupname, 'group_id' => $this->GlobalModel->getGroupName($item->am_group)->ag_id, 'image' => $img);
                 return Response::json($data);
                 break;
             case 'getOrderedRooms':
                 if (Input::has('date') && Input::has('date_to')) {
                     $datefrom = Input::get('date');
                     $dateto = Input::get('date_to');
                 } else {
                     $datefrom = $dateto = date('Y-m-d');
                 }
                 $Orders = new Orders();
                 $rooms = $Orders->getRoomOrderReserve($datefrom, $dateto);
                 $order_room = array();
                 foreach ($rooms as $room) {
                     $data = array('package_id' => $room->order_packageid, 'or_roomid' => json_decode($room->or_roomid));
                     array_push($order_room, $data);
                 }
                 //
                 //                    $rooms = $Packages->getAllPackages();
                 //                    foreach($rooms as $room){
                 //                        foreach(json_decode($room->pc_itemid) as $pc){
                 //                                $data = array(
                 //                                    'id'        =>  $pc->id,
                 //                                    'quantity'  =>  $pc->quantity
                 //                                );
                 //                                array_push($rooms_, $data);
                 //                        }
                 //                    }
                 $package_rooms = array();
                 $pcg_id = array();
                 $rooms_ = array();
                 if (Input::has('package_id')) {
                     $id = Input::get('package_id');
                     $rooms = $Packages->getAllPackagesByID($id);
                     foreach ($rooms as $room) {
                         foreach (json_decode($room->pc_itemid) as $pc) {
                             array_push($pcg_id, $pc->id);
                             $data = array('id' => $pc->id, 'quantity' => $pc->quantity);
                             array_push($rooms_, $data);
                         }
                         $allAmenities = Amenities::join('tbl_amenities_group', 'ag_id', '=', 'am_group')->where('ag_groupname', 'Room')->whereNotIn('am_id', $pcg_id)->get();
                         foreach ($allAmenities as $aM) {
                             $data = array('or_roomid' => $aM->am_id);
                             array_push($package_rooms, array_filter($data));
                         }
                     }
                 }
                 $data = array('order_rooms' => $order_room, 'package_rooms' => $package_rooms, 'rooms' => $rooms_);
                 return Response::json(array('result' => $data));
                 break;
         }
     }
 }
Ejemplo n.º 11
0
 public function ajax()
 {
     /**@$Logger This for instantiate of new translog.*/
     /**@$USER This for instantiate of new user.*/
     /**@$type This for input type.*/
     $Logger = new TransLog();
     $UserModel = new User();
     $type = Input::get('type');
     if ($type) {
         switch ($type) {
             case 'users-list':
                 $pending = DB::table('tbl_users');
                 $dtResult = GlobalController::setDatatable($pending, array('id', 'user_fname', 'user_lname', 'user_email', 'user_username', 'user_status', 'user_type'), 'id');
                 foreach ($dtResult['objResult'] as $aRow) {
                     try {
                         $pro = $aRow->user_type;
                     } catch (Exception $ex) {
                         $pro = 0;
                     }
                     switch ($pro) {
                         case 1:
                             $pro = 'Admin';
                             break;
                         case 0:
                         case 2:
                             $pro = 'Default';
                             break;
                     }
                     $data = array($aRow->id, $aRow->user_fname, $aRow->user_lname, $aRow->user_email, $aRow->user_username, $aRow->user_status ? "Active" : "Inactive", $pro, '', '<div class="button-container">' . '<button class="btn-blue-admin btn-view-item" data-id="' . $aRow->id . '">View</button>' . '</div>');
                     $dtResult['aaData'][] = $data;
                 }
                 unset($dtResult['objResult']);
                 echo json_encode($dtResult);
                 break;
             case 'validateusername':
                 $input = Input::all();
                 $rules = array('user_username' => 'required|between:6,20|unique:tbl_users');
                 $validator = Validator::make($input, $rules);
                 if ($validator->fails()) {
                     $result = "Not unique";
                 } else {
                     $result = "unique";
                 }
                 return Response::json(array('result' => $result));
                 break;
             case 'validateuseremail':
                 $input = Input::all();
                 $rules = array('user_email' => 'Required|unique:tbl_users|email');
                 $validator = Validator::make($input, $rules);
                 if ($validator->fails()) {
                     $result = "Not unique";
                 } else {
                     $email = Input::get('user_email');
                     $explode = explode('.', $email);
                     if (strlen($explode[1]) < 2) {
                         $result = "Not unique";
                     } else {
                         $result = "unique";
                     }
                 }
                 return Response::json(array('result' => $result));
                 break;
             case 'addnewmember':
                 $rules = array('salutation' => 'required|not_in:default', 'user_username' => 'Required|unique:tbl_users', 'fname' => 'required', 'mname' => 'alpha_spaces', 'lname' => 'required', 'user_email' => 'required|email|unique:tbl_users');
                 Validator::extend('alpha_spaces', function ($attribute, $value) {
                     return preg_match('/^[\\pL\\s]+$/u', $value);
                 });
                 $messages = array("alpha_spaces" => "The :attribute may only contain letters and spaces.");
                 $validator = Validator::make(Input::all(), $rules, $messages);
                 if ($validator->fails()) {
                     return Response::json(array('result' => $validator->messages()));
                 } else {
                     $checkEmailNotif = "Registration Complete. Please check your email for confirmation. Thank you!";
                     $temp_id = "";
                     $input_email = Input::get('user_email');
                     $input_username = Input::get('user_username');
                     $input_fname = Input::get('fname');
                     $input_lname = Input::get('lname');
                     $input_mname = Input::get('mname');
                     $user_countryId = Input::get('user_countryId');
                     $input_userrole = Input::get('user_role');
                     $input_salutation = Input::get('salutation');
                     $confirmation_code = str_random(25);
                     $password = Input::get('password_confirmation');
                     //insert data
                     $arrayInsert = array('user_email' => "{$input_email}", 'user_username' => "{$input_username}", 'user_fname' => "{$input_fname}", 'user_lname' => "{$input_lname}", 'user_mname' => "{$input_mname}", 'user_type' => "{$input_userrole}", 'user_salutation' => "{$input_salutation}", 'user_emailverification' => "{$confirmation_code}", 'user_isFirstLogin' => 0, 'user_status' => 1, 'user_isNew' => 0, 'user_password' => $password);
                     $insertRegistration = $this->GlobalModel->insertModel('tbl_users', $arrayInsert);
                     $this->TransLog->transLogger('User Module', 'Added New User', DB::getPdo()->lastInsertId());
                 }
         }
     }
 }