<?php
class Administration{

    public $model;
    
    public function __construct(){
        $this->model = new Model();
    }

    /** Location/Branch ***************************************************************************/
    
    public function getBranchInfo($condition){
        return $this->model->findOne("locations", $condition);
    }
    public function checkIfBranchExists($condition){
        return count($this->model->findOne("locations", $condition)) > 0 ? true : false;
    }
    public function registerBranch($fields, $values){
        return $this->model->insertdata("locations", $fields, $values);
    }
    public function retrieveAllBranches($pageno, $limit){
        $data = $this->model->paginate("locations", " 1 ORDER BY location ASC", $pageno, $limit);
        return $data;
    }
    public function retrieveBranchByStatus($status, $pageno, $limit){
        $data = $this->model->paginate("locations", "status LIKE '$status' ORDER BY location ASC", $pageno, $limit);
        return $data;
    }    
    public function retrieveBranchByQuery($query, $pageno, $limit,$field = "*"){
        $data = $this->model->paginate("locations", $query, $pageno, $limit,$field);
        return $data;
    }    
    public function updateBranchDetails($query, $id){
        return $this->model->update('locations', $query, "WHERE id = $id");
    }    
    /** End of Location/Branch *****************************************************************************************************/
    
    /** Marketers Target *****************************************************************************************************/
    public function getMarketerTargetInfo($condition){
        return $this->model->findOne("marketertarget", $condition);
    }
    public function checkIfMarketerTargetExists($condition){
        return count($this->model->findOne("marketertarget", $condition)) > 0 ? true : false;
    }
    public function registerMarketerTarget($fields, $values){
        return $this->model->insertdata("marketertarget", $fields, $values);
    }
    public function retrieveAllMarketerTarget($pageno, $limit){
        $data = $this->model->paginate("marketertarget", " 1 ORDER BY groupname ASC", $pageno, $limit);
        return $data;
    }
    public function retrieveMarketerTargetByStatus($status, $pageno, $limit){
        $data = $this->model->paginate("marketertarget", "status LIKE '$status'", $pageno, $limit);
        return $data;
    }    
    public function retrieveMarketerTargetByQuery($query, $pageno, $limit,$field = "*"){
        $data = $this->model->paginate("marketertarget", $query, $pageno, $limit,$field);
        return $data;
    }    
    public function updateMarketerTargetDetails($query, $id){
        return $this->model->update('marketertarget', $query, "WHERE id = $id");
    }    
    /** End of Marketers Target *****************************************************************************************************/
    
    /** Commission Category***************************************************************************/
    public function getCommissionCategoryInfo($condition){
        return $this->model->findOne("commissioncategory", $condition);
    }
    public function checkIfCommissionCategoryExists($condition){
        return count($this->model->findOne("commissioncategory", $condition)) > 0 ? true : false;
    }
    public function registerCommissionCategory($fields, $values){
        return $this->model->insertdata("commissioncategory", $fields, $values);
    }
    public function updateCommissionCategoryDetails($query, $id){
        return $this->model->update('commissioncategory', $query, "WHERE id = $id");
    }    
    /** End of Commission category******* *****************************************************************************************************/ 
    
    /** Products ***************************************************************************/
    
    public function getProductInfo($condition){
        return $this->model->findOne("products", $condition);
    }
    public function checkIfProductExists($condition){
        return count($this->model->findOne("products", $condition)) > 0 ? true : false;
    }
    public function registerProduct($fields, $values){
        return $this->model->insertdata("products", $fields, $values);
    }
    public function retrieveAllProduct($pageno, $limit){
        $data = $this->model->paginate("products", " 1 ORDER BY id ASC", $pageno, $limit);
        return $data;
    }
    public function retrieveProductByStatus($status, $pageno, $limit){
        $data = $this->model->paginate("products", "status LIKE '$status' ORDER BY id ASC", $pageno, $limit);
        return $data;
    }    
    public function retrieveProductByQuery($query, $pageno, $limit,$field = "*"){
        $data = $this->model->paginate("products", $query, $pageno, $limit,$field);
        return $data;
    }    
    public function updateProductDetails($query, $id){
        return $this->model->update('products', $query, "WHERE id = $id");
    }    
    public function getLastID(){
        return $this->model->lastId();
    }
    /** End of Products *****************************************************************************************************/
    
    /** Transactions ***************************************************************************/
    
    public function getTransactionInfo($condition){
        return $this->model->findOne("transactions", $condition);
    }
    public function registerTransaction($fields, $values){
        return $this->model->insertdata("transactions", $fields, $values);
    }
    public function updateTransactionDetails($query, $id){
        return $this->model->update('transactions', $query, "WHERE id = $id");
    }    
    
    /** End of Transactions *****************************************************************************************************/

    /** ProductItems ***************************************************************************/
    
    public function getProductItemInfo($condition){
        return $this->model->findOne("productitems", $condition);
    }
    public function registerProductItem($fields, $values){
        return $this->model->insertdata("productitems", $fields, $values);
    }
    public function updateProductItemDetails($query, $id){
        return $this->model->update('productitems', $query, "WHERE id = $id");
    }    
    /** End of Transactions *****************************************************************************************************/

    /** roomcategories ***************************************************************************/
    public function getRoomCategoryInfo($condition){
        return $this->model->findOne("roomcategories", $condition);
    }
    public function registerRoomCategory($fields, $values){
        return $this->model->insertdata("roomcategories", $fields, $values);
    }
    public function updateRoomCategoryDetails($query, $id){
        return $this->model->update('roomcategories', $query, "WHERE id = $id");
    }    
    /** End of roomcategories *****************************************************************************************************/    
    
    /** rooms ***************************************************************************/
    public function getRoomInfo($condition){
        return $this->model->findOne("rooms", $condition);
    }
    public function registerRoom($fields, $values){
        return $this->model->insertdata("rooms", $fields, $values);
    }
    public function updateRoomDetails($query, $id){
        return $this->model->update('rooms', $query, "WHERE id = $id");
    }    
    /** End of roomcategories *****************************************************************************************************/   
    
    /** Assingment Sheet ***************************************************************************/
    public function getAssignmentSheetInfo($condition){
        return $this->model->findOne("assignementsheet", $condition);
    }
    public function registerAssignmentSheet($fields, $values){
        $result = $this->model->insertdata("assignementsheet", $fields, $values);
        if($result){
            return $this->model->lastId();
        }else{
            return null;
        }
    }
    public function updateAssignmentSheetDetails($query, $id){
        return $this->model->update('assignementsheet', $query, "WHERE id = $id");
    }    
    /** End of Assingment Sheet *****************************************************************************************************/ 
    
    /** Assingment Sheet Items***************************************************************************/
    public function getAssignmentSheetItemsInfo($condition){
        return $this->model->findOne("assignmentsheetitems", $condition);
    }
    public function registerAssignmentSheetItems($fields, $values){
        return $this->model->insertdata("assignmentsheetitems", $fields, $values);
    }
    public function updateAssignmentSheetItemsDetails($query, $id){
        return $this->model->update('assignmentsheetitems', $query, "WHERE id = $id");
    }    
    /** End of Assingment Sheet Items*****************************************************************************************************/ 
    
    /** Maintenance Request ******************************************************************************************/
    public function getMaintenanceInfo($condition){
        return $this->model->findOne("maintenance", $condition);
    }
    public function registerMaintenance($fields, $values){
        return $this->model->insertdata("maintenance", $fields, $values);
    }
    public function updateMaintenanceDetails($query, $id){
        return $this->model->update('maintenance', $query, "WHERE id = $id");
    }    
    /** End of Maintenance Request*****************************************************************************************************/ 

    /** Cleaning Checklist Items ******************************************************************************************/
    public function getCheckListItemsInfo($condition){
        return $this->model->findOne("cleaningchecklistitems", $condition);
    }
    public function registerCheckListItems($fields, $values){
        return $this->model->insertdata("cleaningchecklistitems", $fields, $values);
    }
    public function updateCheckListItemsDetails($query, $id){
        return $this->model->update('cleaningchecklistitems', $query, "WHERE id = $id");
    }    
    /** End of Cleaning Checklist Items************************************************************************************************/ 

    /** Work Order ******************************************************************************************/
    public function getWorkOrderInfo($condition){
        return $this->model->findOne("workorder", $condition);
    }
    public function registerWorkOrder($fields, $values){
        return $this->model->insertdata("workorder", $fields, $values);
    }
    public function updateWorkOrderDetails($query, $id){
        return $this->model->update('workorder', $query, "WHERE id = $id");
    }    
    /** End of Work Order************************************************************************************************/ 
    
    /** Room Cleaning Checklist ******************************************************************************************/
    public function getRoomCheckListInfo($condition){
        return $this->model->findOne("cleaningchecklist", $condition);
    }
    public function registerRoomCheckList($fields, $values){
        return $this->model->insertdata("cleaningchecklist", $fields, $values);
    }
    public function updateRoomCheckListDetails($query, $id){
        return $this->model->update('cleaningchecklist', $query, "WHERE id = $id");
    }    
    /** End of Room Cleaning Checklist********************************************************************************************/ 

    /** Lost and Found Register ******************************************************************************************/
    public function getLostFoundInfo($condition){
        return $this->model->findOne("lostfoundregister", $condition);
    }
    public function registerLostFound($fields, $values){
        return $this->model->insertdata("lostfoundregister", $fields, $values);
    }
    public function updateLostFoundDetails($query, $id){
        return $this->model->update('lostfoundregister', $query, "WHERE id = $id");
    }    
    /** End of Lost and Found Register********************************************************************************************/ 

    /** Department ******************************************************************************************/
    public function getDepartmentInfo($condition){
        return $this->model->findOne("department", $condition);
    }
    public function registerDepartment($fields, $values){
        return $this->model->insertdata("department", $fields, $values);
    }
    public function updateDepartmentDetails($query, $id){
        return $this->model->update('department', $query, "WHERE id = $id");
    }    
    /** End of Lost and Found Register********************************************************************************************/ 

    /** Reviews ******************************************************************************************/
    public function getReviewInfo($condition){
        return $this->model->findOne("reviews", $condition);
    }
    public function registerReview($fields, $values){
        return $this->model->insertdata("reviews", $fields, $values);
    }
    public function updateReviewDetails($query, $id){
        return $this->model->update('reviews', $query, "WHERE id = $id");
    }    
    /** End of Lost and Found Register********************************************************************************************/ 

    /** Cost Center ******************************************************************************************/
    public function getCostCenterInfo($condition){
        return $this->model->findOne("costcenter", $condition);
    }
    public function registerCostCenter($fields, $values){
        return $this->model->insertdata("costcenter", $fields, $values);
    }
    public function updateCostCenterDetails($query, $id){
        return $this->model->update('costcenter', $query, "WHERE id = $id");
    }    
    /** End of Cost Center********************************************************************************************/ 

    /** Discount Coupon ******************************************************************************************/
    public function getDiscountCouponInfo($condition){
        return $this->model->findOne("discountcoupon", $condition);
    }
    public function registerDiscountCoupon($fields, $values){
        return $this->model->insertdata("discountcoupon", $fields, $values);
    }
    public function updateDiscountCouponDetails($query, $id){
        return $this->model->update('discountcoupon', $query, "WHERE id = $id");
    }    
    /** End of Discount Coupon********************************************************************************************/ 
                
    /** Booking Plan ******************************************************************************************/
    public function getBookingPlanInfo($condition){
        return $this->model->findOne("bookingplan", $condition);
    }
    public function registerBookingPlan($fields, $values){
        return $this->model->insertdata("bookingplan", $fields, $values);
    }
    public function updateBookingPlanDetails($query, $id){
        return $this->model->update('bookingplan', $query, "WHERE id = $id");
    }    
    /** End of Booking Plan********************************************************************************************/ 
                
    /** Rate Code ******************************************************************************************/
    public function getRateCodeInfo($condition){
        return $this->model->findOne("ratecode", $condition);
    }
    public function registerRateCode($fields, $values){
        return $this->model->insertdata("ratecode", $fields, $values);
    }
    public function updateRateCodeDetails($query, $id){
        return $this->model->update('ratecode', $query, "WHERE id = $id");
    }    
    /** End of Rate Code******************************************************************************************/ 
                
    /** Licence Agreement ******************************************************************************************/
    public function getLicenceaInfo($condition){
        return $this->model->findOne("licencea", $condition);
    }
    public function registerLicencea($fields, $values){
        return $this->model->insertdata("licencea", $fields, $values);
    }
    public function updateLicenceaDetails($query, $id){
        return $this->model->update('licencea', $query, "WHERE id = $id");
    }    
    /** End of Licence Agreement******************************************************************************************/ 

    /** Dining Tables ******************************************************************************************/
    public function getDiningTableInfo($condition){
        return $this->model->findOne("diningtables", $condition);
    }
    public function registerDiningTable($fields, $values){
        return $this->model->insertdata("diningtables", $fields, $values);
    }
    public function updateDiningTableDetails($query, $id){
        return $this->model->update('diningtables', $query, "WHERE id = $id");
    }    
    /** End of Dining Tables****************************************************************************************/ 

    /** Table Reservtion ******************************************************************************************/
    public function getTableReservationInfo($condition){
        return $this->model->findOne("tablereservation", $condition);
    }
    public function registerTableReservation($fields, $values){
        return $this->model->insertdata("tablereservation", $fields, $values);
    }
    public function updateTableReservationDetails($query, $id){
        return $this->model->update('tablereservation', $query, "WHERE id = $id");
    }    
    /** End of Table Reservtion****************************************************************************************/ 
    
    public function getRowsNumber($table){
        return count($this->model->findAll($table));
    }

    public function executeByQuerySelector($query){
        $data = $this->model->exec_query($query);
        return $data;
    }
}
?>