Ejemplo n.º 1
0
 /**
  * Delete a tax rule
  * @param $result
  * @return mixed
  */
 public function deleteTaxRule($result)
 {
     // validate input
     if (!is_numeric($this->data->id)) {
         $result['error'] = "A valid id must be supplied";
         return $result;
     }
     if ($this->data->id == 1) {
         $result['error'] = "The No Tax rule cannot be deleted";
         return $result;
     }
     $taxRuleMdl = new TaxRulesModel();
     $qresult = $taxRuleMdl->remove($this->data->id);
     if ($qresult === false) {
         $result['error'] = "Could not delete the tax rule: " . $taxRuleMdl->errorInfo;
     } else {
         $result['data'] = true;
         $this->broadcastTaxUpdate();
         // log data
         Logger::write("Tax rule deleted with id:" . $this->data->id, "TAX");
     }
     return $result;
 }