diff --git a/module/program/control.php b/module/program/control.php index 171eabc250..5e33f029dd 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -419,29 +419,27 @@ class program extends control * Delete a program. * * @param int $programID - * @param string $confirm yes|no * @access public * @return void */ - public function delete($programID, $confirm = 'no') + public function delete($programID) { $childrenCount = $this->dao->select('count(*) as count')->from(TABLE_PROGRAM)->where('parent')->eq($programID)->andWhere('deleted')->eq(0)->fetch('count'); if($childrenCount) { if($this->viewType == 'json' or (defined('RUN_MODE') && RUN_MODE == 'api')) return $this->send(array('result' => 'fail', 'message' => 'Cannot delete the program has children')); - return print(js::alert($this->lang->program->hasChildren)); + return $this->send(array('result' => 'fail', 'callback' => "zui.Modal.alert('{$this->lang->program->hasChildren}');")); } $productCount = $this->dao->select('count(*) as count')->from(TABLE_PRODUCT)->where('program')->eq($programID)->andWhere('deleted')->eq(0)->fetch('count'); - if($productCount) return print(js::alert($this->lang->program->hasProduct)); + if($productCount) return $this->send(array('result' => 'fail', 'callback' => "zui.Modal.alert('{$this->lang->program->hasProduct}');")); $program = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($programID)->fetch(); - if($confirm == 'no') return print(js::confirm(sprintf($this->lang->program->confirmDelete, $program->name), $this->createLink('program', 'delete', "programID=$programID&confirm=yes"))); $this->dao->update(TABLE_PROGRAM)->set('deleted')->eq(1)->where('id')->eq($programID)->exec(); $this->loadModel('action')->create('program', $programID, 'deleted', '', ACTIONMODEL::CAN_UNDELETED); - echo js::reload('parent'); + return $this->send(array('result' => 'success')); } /** diff --git a/module/program/js/browse.ui.js b/module/program/js/browse.ui.js index b90698ca28..f704592753 100644 --- a/module/program/js/browse.ui.js +++ b/module/program/js/browse.ui.js @@ -35,7 +35,7 @@ window.confirmDelete = function(projectID, module, projectName) zui.Modal.confirm({message: confirmDeleteLang[module].replace('%s', projectName), icon:'icon-info-sign', iconClass: 'warning-pale rounded-full icon-2x'}).then((res) => { - if(res) $.get(deleteURL, function(){loadCurrentPage();}); + if(res) $.ajaxSubmit({url: deleteURL, load: true}); }); }