public function ratecard($id = '')
 {
     $this->loadS_model('common');
     $this->loadS_model('defination');
     $this->setViewData('box_header', "Ratecard");
     $this->setViewData('object', "ratecard");
     $this->setViewData('rate_card', array());
     $this->setViewData('action', 'insert');
     if ($id) {
         $this->setViewData('action', 'update');
     }
     $this->setViewData('list_headers', array("city" => 'City', "special_type" => 'Special Type', "size" => 'Tonnage', "mode" => 'Mode', "mode_unit" => 'Unit', "mode_unit_cost" => 'cost', "waiting_hour_unit" => 'Wating hour', "wating_hour_cost" => 'Wating hour cost', "free_wating_time" => 'Free wating time', "km_limit" => 'KM limit', "additional_km_unit" => 'Additional KM unit', "additional_km_cost" => 'Additional KM unit cost', "special_type_multiplier" => 'Special type multiplier', "labour_rate" => 'Labour rate', "action" => 'Action'));
     if ($this->request('action') == 'insert') {
         $rate_card = $this->request('rate_card');
         if ($this->Model_common->getData(TBL_RATE_CARD, array_make(array('city', 'special_type', 'size', 'mode'), $rate_card))) {
             $this->updateRecord(TBL_RATE_CARD, array('id' => $id), $rate_card);
             $this->set_success_responce("The rate card has been updated.");
             return;
         }
         $this->insertRecord(TBL_RATE_CARD, $rate_card);
         $this->set_success_responce("The rate card has been saved.");
         return;
     } elseif ($this->request('action') == 'update') {
         $rate_card = $this->request('rate_card');
         $this->updateRecord(TBL_RATE_CARD, array('id' => $id), $rate_card);
         $this->set_success_responce("The rate card has been updated.");
         return;
     }
     $this->process_ratecard($id);
     //        $this->debug_view(true);
     $this->render_view('ratecard', 'defination');
 }
Example #2
0
 public function check_with_specific_fields_with_errors($table, $cond_fields, $data, $extra = '')
 {
     $errors = array();
     if (!$data) {
         return false;
     }
     $field_where_or = array_make(array_keys($cond_fields), $data);
     if ($field_where_or) {
         foreach ($field_where_or as $key => $value) {
             if ($this->check_with_specific($table, $key, $value, $extra)) {
                 $errors[] = $cond_fields[$key];
             }
         }
     }
     return $errors;
 }
Example #3
0
 function _createSecurityChecker($aAccountPermissionPairs)
 {
     $checkers = array();
     foreach ($aAccountPermissionPairs as $elem) {
         //$elem can be
         // 1) a single element then it should be an account eg OA_ADMIN_ACCOUNT
         // 2) an 2 element array key => value
         //    - KEY stores account(s) and can be:
         //        * a single account element eg OA_ADMIN_ACCOUNT
         //        * an array of accounts eg. array(OA_ADMIN_ACCOUNT, OA_MANAGER_ACCOUNT)
         //    - VALUE stores permissions(s) and can be:
         //        * a single permission element eg OA_OA_PERM_ZONE_INVOCATION
         //        * an array of permissions eg. array(OA_PERM_ZONE_INVOCATION, OA_PERM_SUPER_ACCOUNT)
         // If KEY is an array it is assumed that every account from that array should be associated with VALUE permissions
         if (is_array($elem)) {
             //(account,perm) pair
             foreach ($elem as $aPairAccounts => $aPairPermissions) {
                 //a hack to get key=> val
                 break;
             }
             $aPairAccounts = array_make($aPairAccounts);
             $aPairPermissions = array_make($aPairPermissions);
             for ($i = 0; $i < count($aPairAccounts); $i++) {
                 $checkers[] = new OA_Admin_Menu_Compound_Checker(array(new OA_Admin_SectionAccountChecker($aPairAccounts[$i]), new OA_Admin_SectionPermissionChecker($aPairPermissions)), 'AND');
             }
         } else {
             //just account only, no associated permission, add to accounts array
             $justAccounts[] = $elem;
         }
     }
     if (!empty($justAccounts)) {
         $checkers[] = new OA_Admin_SectionAccountChecker($justAccounts);
         //add checker for accounts only
     }
     return new OA_Admin_Menu_Compound_Checker($checkers, 'OR');
 }