connect(); $query = "SELECT difflist_role_id FROM " . ENT_GROUPBASKET_DIFFLIST_ROLES . " where basket_id= '" . $_SESSION['current_basket']['id'] . "' and group_id = '" . $_SESSION['user']['primarygroup'] . "' and action_id = " . $id_action; $db->query($query); if($db->nb_result() > 0) { $rolesLine = $db->fetch_object(); $roleFromParam = $rolesLine->difflist_role_id; } $res_id = $values[0]; //WF COMPUTING require_once('modules/basket/class/class_modules_tools.php'); $myBasket = new basket(); $myTurnInTheWF = false; //is it my turn in the WF ? $myTurnInTheWF = $myBasket->isItMyTurnInTheWF( $_SESSION['user']['UserId'], $res_id, $coll_id ); $frm_str .= '

' . _PROCESS_STEP . ', ' . _DOCUMENT . ' ' . _NUM . ' ' . $res_id . '

'; if ($myTurnInTheWF) { $rolesArr = array(); //get the roles in the wf of the user $rolesArr = $myBasket->whatAreMyRoleInTheWF( $_SESSION['user']['UserId'], $res_id, $coll_id ); //print_r($rolesArr); $foundARoleForMe = false; if (!empty($rolesArr)) { $rolesInTheWF = array(); for ($cptRoles=0;$cptRoleswhatIsMySequenceForMyRole( $_SESSION['user']['UserId'], $res_id, $coll_id, $rolesArr[$cptRoles] ); array_push( $rolesInTheWF, array( 'role' => $rolesArr[$cptRoles], 'sequence' => $sequence, 'isThereSomeoneAfterMeInTheWF' =>$myBasket->isThereSomeoneAfterMeInTheWF( $res_id, $coll_id, $rolesArr[$cptRoles], $sequence ), 'theNextInTheWF' =>$myBasket->whoseTheNextInTheWF( $res_id, $coll_id, $rolesArr[$cptRoles], $sequence ), 'isThereSomeoneBeforeMeInTheWF' =>$myBasket->isThereSomeoneBeforeMeInTheWF( $res_id, $coll_id, $rolesArr[$cptRoles], $sequence ), 'thePreviousInTheWF' =>$myBasket->whoseThePreviousInTheWF( $res_id, $coll_id, $rolesArr[$cptRoles], $sequence ), ) ); } } } //print_r($rolesInTheWF); } //WF general view for the agent if ($myTurnInTheWF) { $frm_str .= '
'; $frm_str .= ''; $frm_str .= ''; $frm_str .= ''; $frm_str .= ''; $frm_str .= ''; $countRoles = count($rolesInTheWF); for ($cptR=0;$cptR<$countRoles;$cptR++) { $frm_str .= '

'; $frm_str .= ' >> ' . _WF . ' : ' . _ROLE . ' ' . $rolesInTheWF[$cptR]['role'] . ''; $frm_str .= ' '; $frm_str .= '

'; $frm_str .= '
'; $frm_str .= ''; if ($rolesInTheWF[$cptR]['isThereSomeoneAfterMeInTheWF']) { $textButton = '>> ' . _ADVANCE_TO . ' ' . $rolesInTheWF[$cptR]['theNextInTheWF'] . ' >>'; } else { $textButton = _VALID_STEP . ' ' . $rolesInTheWF[$cptR]['role']; } $frm_str .= ''; $frm_str .= ''; $frm_str .= ''; if ($rolesInTheWF[$cptR]['isThereSomeoneBeforeMeInTheWF']) { $frm_str .= ''; $frm_str .= ''; $frm_str .= ''; } $frm_str .= '
'; $frm_str .= $textButton; $frm_str .= '
'; $frm_str .= '<< ' . _BACK_TO . ' ' . $rolesInTheWF[$cptR]['thePreviousInTheWF'] . ' <<'; $frm_str .= '
'; $frm_str .= '
'; } $frm_str .= '
'; } else { $frm_str .= _ITS_NOT_MY_TURN_IN_THE_WF . '
'; } if (!$foundARoleForMe) { $frm_str .= _NO_AVAILABLE_ROLE_FOR_ME_IN_THE_WF . '
'; } $frm_str .='
'; $frm_str .='
'; $frm_str .=''; $frm_str .='
'; return addslashes($frm_str); } function check_form($form_id, $values) { $res_id = get_value_fields($values, 'res_id'); $coll_id = get_value_fields($values, 'coll_id'); $role = get_value_fields($values, 'role'); $way = get_value_fields($values, 'way'); if (empty($res_id) || empty($coll_id) || empty($role) || empty($way)) { $_SESSION['action_error'] = _MISSING_FIELD; return false; } else { return true; } } function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form) { if (empty($values_form) || count($arr_id) < 1) { return false; } $res_id = get_value_fields($values_form, 'res_id'); $coll_id = get_value_fields($values_form, 'coll_id'); $role = get_value_fields($values_form, 'role'); $way = get_value_fields($values_form, 'way'); $core_tools = new core_tools(); $dbActions= new dbquery(); $dbActions->connect(); require_once('modules/basket/class/class_modules_tools.php'); $b = new basket(); //WF COMPUTING $myTurnInTheWF = false; //is it my turn in the WF ? $myTurnInTheWF = $b->isItMyTurnInTheWF( $_SESSION['user']['UserId'], $res_id, $coll_id, $role ); if ($myTurnInTheWF) { $someoneAfterMe =true; $sequence = $b->whatIsMySequenceForMyRole( $_SESSION['user']['UserId'], $res_id, $coll_id, $role ); $someoneAfterMe = $b->isThereSomeoneAfterMeInTheWF( $res_id, $coll_id, $role, $sequence ); $updateStatus = true; $theNewStatus = ''; // Select statuses from groupbasket $db = new dbquery(); $db->connect(); $query = "SELECT status_id, label_status FROM " . GROUPBASKET_STATUS . " left join " . $_SESSION['tablename']['status'] . " on status_id = id " . " where basket_id= '" . $_SESSION['current_basket']['id'] . "' and group_id = '" . $_SESSION['user']['primarygroup'] . "' and action_id = " . $id_action; $db->query($query); if($db->nb_result() > 0) { $status = $db->fetch_object(); $theNewStatus = $status->status_id; } else { $updateStatus = false; } //UPDATE STATUS IF NOBODY AFTER ME if ( !$someoneAfterMe && ($updateStatus && $theNewStatus <> '') && $way == 'forward' ) { $queryUpdateStatus = "update " . $table . " set status = '" . $theNewStatus . "' where res_id = " . $res_id; $db->query($queryUpdateStatus); } $b->moveInTheWF( $way, $coll_id, $res_id, $role, $_SESSION['user']['UserId'] ); require_once('modules/entities/class/class_manage_listdiff.php'); $listdiff = new diffusion_list(); $_SESSION['process']['diff_list'] = $listdiff->get_listinstance( $res_id, false, $coll_id ); if ($way == 'forward') { $histText = _FORWARD_IN_THE_WF; } else { $histText = _BACK_IN_THE_WF; } require_once('core/class/class_security.php'); $sec = new security(); $view = $sec->retrieve_view_from_coll_id($coll_id); require_once('core/class/class_history.php'); $hist = new history(); $hist->add( $view, $res_id, 'UP', 'stepWF' . $way, _DOC_NUM . $res_id . ' ' . $histText . ' ' . $role, $_SESSION['config']['databasetype'], 'apps' ); if (!$someoneAfterMe) { $hist->add( $view, $res_id, 'UP', 'stepWFEND', _DOC_NUM . $res_id . ' ' . _END_OF_THE_WF . ' ' . $role, $_SESSION['config']['databasetype'], 'apps' ); } return array('result' => $arr_id[0].'#', 'history_msg' => ''); } else { $_SESSION['error'] = _ITS_NOT_MY_TURN_IN_THE_WF; return array( 'result' => $arr_id[0] . '#', 'history_msg' => _ITS_NOT_MY_TURN_IN_THE_WF ); } return false; } /** * Get the value of a given field in the values returned by the form * * @param $values Array Values of the form to check * @param $field String the field * @return String the value, false if the field is not found **/ function get_value_fields($values, $field) { for ($i=0; $i