Exemplo n.º 1
0
 public function saveBPartnerGroup()
 {
     $this->log->showLog(2, "Access saveBPartnerGroup()");
     // die;
     global $xoopsDB, $saveHandler, $createdby, $timestamp, $defaultorganization_id;
     $tablename = "sim_bpartnergroup";
     $pkey = "bpartnergroup_id";
     $keyword = "BPartnerGroup";
     $controlfieldname = "bpartnergroup_name";
     $insertCount = $saveHandler->ReturnInsertCount();
     $this->log->showLog(3, "Start Insert({$insertCount} records)");
     if ($insertCount > 0) {
         $arrfield = array($controlfieldname, "debtoraccounts_id", "creditoraccounts_id", "description", "isactive", "defaultlevel", "created", "createdby", "updated", "updatedby", "organization_id");
         $arrfieldtype = array('%s', '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%s', '%d', '%d');
         // Yes there are INSERTs to perform...
         for ($currentRecord = 0; $currentRecord < $insertCount; $currentRecord++) {
             $arrvalue = array($saveHandler->ReturnInsertField($currentRecord, $controlfieldname), $saveHandler->ReturnInsertField($currentRecord, "debtoraccounts_id"), $saveHandler->ReturnInsertField($currentRecord, "creditoraccounts_id"), $saveHandler->ReturnInsertField($currentRecord, "description"), $saveHandler->ReturnInsertField($currentRecord, "isactive"), $saveHandler->ReturnInsertField($currentRecord, "defaultlevel"), $timestamp, $createdby, $timestamp, $createdby, $defaultorganization_id);
             $controlvalue = $saveHandler->ReturnInsertField($currentRecord, $controlfieldname);
             $this->InsertRecord($tablename, $arrfield, $arrvalue, $arrfieldtype, $controlvalue, $pkey);
             // Now we execute this query
         }
     }
     $updateCount = $saveHandler->ReturnUpdateCount();
     $this->log->showLog(3, "Start update({$updateCount} records)");
     if ($updateCount > 0) {
         $arrfield = array($controlfieldname, "debtoraccounts_id", "creditoraccounts_id", "description", "isactive", "defaultlevel", "updated", "updatedby", "isdeleted");
         $arrfieldtype = array('%s', '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d');
         // Yes there are UPDATEs to perform...
         for ($currentRecord = 0; $currentRecord < $updateCount; $currentRecord++) {
             $arrvalue = array($saveHandler->ReturnUpdateField($currentRecord, $controlfieldname), $saveHandler->ReturnUpdateField($currentRecord, "debtoraccounts_id"), $saveHandler->ReturnUpdateField($currentRecord, "creditoraccounts_id"), $saveHandler->ReturnUpdateField($currentRecord, "description"), $saveHandler->ReturnUpdateField($currentRecord, "isactive"), $saveHandler->ReturnUpdateField($currentRecord, "defaultlevel"), $timestamp, $createdby, $saveHandler->ReturnUpdateField($currentRecord, "isdeleted"));
             $controlvalue = $saveHandler->ReturnUpdateField($currentRecord, $controlfieldname);
             $this->UpdateRecord($tablename, $pkey, $saveHandler->ReturnUpdateField($currentRecord), $arrfield, $arrvalue, $arrfieldtype, $controlvalue);
         }
     }
     $ispurge = 0;
     $deleteCount = $saveHandler->ReturnDeleteCount();
     $this->log->showLog(3, "Start delete/purge({$deleteCount} records)");
     $classname = "class/{$keyword}.inc.php";
     include $classname;
     $this->log->showLog(3, "Include {$classname} successfully");
     $o = new BPartnerGroup();
     $this->log->showLog(3, "Inilialize {$keyword}()");
     if ($deleteCount > 0) {
         for ($currentRecord = 0; $currentRecord < $deleteCount; $currentRecord++) {
             $record_id = $saveHandler->ReturnDeleteField($currentRecord);
             $o->fetchBPartnerGroup($record_id);
             $controlvalue = $o->bpartnergroup_name;
             $isdeleted = $o->isdeleted;
             if ($o->allowDelete($record_id)) {
                 $this->DeleteRecord($tablename, $pkey, $record_id, $controlvalue, $isdeleted);
             } else {
                 $this->failfeedback .= "Cannot delete {$keyword}: {$o->bpartnergroup_name} <br/>";
             }
         }
     }
     //$this->failfeedback.="asdasdpasd<br/>\n";
     //$this->failfeedback.="123 3443<br/>\n";
     //$this->failfeedback.="234 45656523 234<br/>\n";
     if ($this->failfeedback != "") {
         $this->failfeedback .= "Warning!<br/>\n" . $this->failfeedback;
     }
     $saveHandler->setErrorMessage($this->failfeedback);
     $saveHandler->CompleteSave();
 }