Пример #1
0
 protected function btnDelete_Click($strFormId, $strControlId, $strParameter)
 {
     $items = $this->dtgContact->getSelected('ContactId');
     // Show confirm "Are you sure you want to {delete/edit} these objects?"
     if (count($items) > 0) {
         $this->lblWarning->Text = "";
         if (!$this->dlgDelete->Display) {
             $arrToBeSkipped = array();
             foreach ($items as $item) {
                 // Check if any Shipments or Receipts include selected contact
                 if (Shipment::hasContact($item) || Receipt::hasContact($item)) {
                     // append $item to  be skipped
                     $arrToBeSkipped[] = $item;
                 } else {
                     $this->arrToDelete[] = $item;
                 }
             }
             if (count($arrToBeSkipped) > 0) {
                 if (count($arrToBeSkipped) == 1) {
                     $toBe = 'is';
                     $ending = '';
                 } else {
                     $toBe = 'are';
                     $ending = 's';
                 }
                 // Show dialog box "There are {number} {entity_type}s that are not able to be deleted. Would you like to continue the deletion process, skipping these items?"
                 $this->dlgDelete->Text = sprintf("There %s %s contact%s that %s not able to be deleted.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t Would you like to continue the deletion process,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t skipping these item%s?<br />", $toBe, count($arrToBeSkipped), $ending, $toBe, $ending);
                 $this->dlgDelete->ShowDialogBox();
             } else {
                 if (count($this->arrToDelete) > 0) {
                     Contact::DeleteSelected($this->arrToDelete);
                     $this->arrToDelete = array();
                     QApplication::Redirect('');
                 }
             }
             //	print_r(get_class_methods(get_class($this->dlgDelete)));exit;//$this->dlgDelete->ShowDialogBox() ;
         }
     } else {
         $this->lblWarning->Text = "You haven't chosen any Contact to Delete";
     }
 }