* {@internal 
 *   created 2006-01-13
 *   
 *   $Id$
 * }}
 * 
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
$iIdMarked = (int) $_GET['idworkflow'];
plugin_include('workflow', 'classes/class.workflow.php');
$workflows = new Workflows();
$sScript = '';
if ($action == "workflow_delete") {
    $workflows->delete($idworkflow);
    $sScript = '<script type="text/javascript">
                    var right_top = top.content.frames["right"].frames["right_top"];
                    var right_bottom = top.content.frames["right"].frames["right_bottom"];

                    if (right_top) {
                        right_top.location.href = "' . $sess->url('main.php?area=workflow&frame=3') . '";
                    }
                    if (right_bottom) {
                        right_bottom.location.href = "' . $sess->url('main.php?area=workflow&frame=4') . '";
                    }
                </script>';
}
$ui = new UI_Menu();
$workflows->select("idclient = '{$client}' AND idlang = '{$lang}'");
while ($workflow = $workflows->next()) {
 /** Delete a workflow stage
  */
 public function deleteworkflowAction()
 {
     $this->_flashMessenger->addMessage($this->_noChange);
     if ($this->_request->isPost()) {
         $id = (int) $this->_request->getPost('id');
         $del = $this->_request->getPost('del');
         if ($del == 'Yes' && $id > 0) {
             $workflows = new Workflows();
             $where = 'id = ' . $id;
             $workflows->delete($where);
         }
         $this->_flashMessenger->addMessage(self::DELETED);
         $this->_redirect($this->_redirectUrl . 'workflows');
     } else {
         $id = (int) $this->_request->getParam('id');
         if ($id > 0) {
             $workflows = new Workflows();
             $this->view->workflow = $workflows->fetchRow('id=' . $id);
         }
     }
 }
 function create($idworkflow, $idcatlang)
 {
     $this->select("idcatlang = '{$idcatlang}'");
     if ($this->next() !== false) {
         $this->lasterror = i18n("Category already has a workflow assigned", "workflow");
         return false;
     }
     $workflows = new Workflows();
     $workflows->select("idworkflow = '{$idworkflow}'");
     if ($workflows->next() === false) {
         $this->lasterror = i18n("Workflow doesn't exist", "workflow");
         return false;
     }
     $newitem = parent::create();
     if (!$newitem->setWorkflow($idworkflow)) {
         $this->lasterror = $newitem->lasterror;
         $workflows->delete($newitem->getField("idallocation"));
         return false;
     }
     if (!$newitem->setCatLang($idcatlang)) {
         $this->lasterror = $newitem->lasterror;
         $workflows->delete($newitem->getField("idallocation"));
         return false;
     }
     $newitem->store();
     return $newitem;
 }