Exemplo n.º 1
0
 public function is_transaction_valid_post()
 {
     $main_id = $this->input->post('mainId');
     $branch_id = $this->input->post('branchId');
     $return_id_from_branch = $this->input->post('returnIdFromBranch');
     $transaction = $this->input->post('transaction');
     $settings_repo = new Settings_Repository($this->base_model->get_db_instance());
     $branches_repo = new Branches_Repository($this->base_model->get_db_instance());
     $returns_repo = new Returns_Repository($this->base_model->get_db_instance());
     if ($transaction != Transaction_Type::Return_Items) {
         echo 1;
     } else {
         if ($settings_repo->get_settings()->app_id != $main_id) {
             echo -2;
         } else {
             if (!$branches_repo->branch_exists($branch_id)) {
                 echo -1;
             } else {
                 if ($returns_repo->return_exists_via_return_id_from_branch($return_id_from_branch, $branch_id)) {
                     echo 0;
                 } else {
                     echo 2;
                 }
             }
         }
     }
     // valid return
 }