public function confirmDeleteVatObject()
 {
     if ((int) $_GET['vat_id'] && !isset($_POST['vat_id'])) {
         $_POST['vat_id'][] = $_GET['vat_id'];
     }
     if ($_SESSION['count_vats'] == count($_POST['vat_id'])) {
         ilUtil::sendInfo($this->lng->txt('shop_disabled_no_vats'));
         $_SESSION['disable_shop'] = true;
     }
     $c_gui = new ilConfirmationGUI();
     $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performDeleteVat'));
     $c_gui->setHeaderText($this->lng->txt('paya_sure_delete_vats'));
     $c_gui->setCancel($this->lng->txt('cancel'), 'vats');
     $c_gui->setConfirm($this->lng->txt('confirm'), 'performDeleteVat');
     $counter = 0;
     foreach ((array) $_POST['vat_id'] as $vat_id) {
         try {
             $oVAT = new ilShopVats((int) $vat_id);
             $c_gui->addItem('vat_id[]', $oVAT->getId(), $oVAT->getTitle());
             ++$counter;
         } catch (ilShopException $e) {
             ilUtil::sendInfo($e->getMessage());
             return $this->vatsObject();
         }
     }
     if ($counter) {
         $this->tpl->setContent($c_gui->getHTML());
         return true;
     } else {
         $this->vatsObject();
         return true;
     }
 }
Exemplo n.º 2
0
 /**
  * Reads the vat datasets from database.
  * 
  * @access	public 
  * @return	ilShopVatsList
  *  
  */
 public function read()
 {
     $this->vat_list = array();
     $query = "SELECT * FROM payment_vats ";
     $query .= "WHERE 1 = 1 ";
     if (!in_array($this->getOrderColumn(), array('vat_title', 'vat_rate'))) {
         $this->setOrderColumn('vat_rate');
         $this->setOrderDirection('ASC');
     }
     $order_limit = " ORDER BY " . $this->getOrderColumn() . " " . strtoupper($this->getOrderDirection()) . " ";
     if ((int) $this->getListMax()) {
         $order_limit .= "LIMIT " . $this->getListStart() . ", " . $this->getListMax();
     }
     $res = $this->db->query($query . $order_limit);
     while ($row = $this->db->fetchObject($res)) {
         $oVAT = new ilShopVats();
         $oVAT->setId($row->vat_id);
         $oVAT->setTitle($row->vat_title);
         $oVAT->setRate($row->vat_rate);
         $this->vat_list[$oVAT->getId()] = $oVAT;
     }
     $res = $this->db->query(str_replace('*', 'COUNT(vat_id) AS num_vat_list', $query));
     while ($row = $this->db->fetchObject($res)) {
         $this->num_vat_list = $row->num_vat_list;
         break;
     }
     return $this;
 }