/**
  *  Show list of actions for element
  *
  *  @param	Object	$object			Object
  *  @param  string	$typeelement	'invoice','propal','order','invoice_supplier','order_supplier','fichinter'
  *	@param	int		$socid			socid of user
  *  @param	int		$forceshowtitle	Show title even if there is no actions to show
  *	@return	int						<0 if KO, >=0 if OK
  */
 function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0)
 {
     global $langs, $conf, $user;
     global $bc;
     require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
     $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement);
     if (!is_array($listofactions)) {
         dol_print_error($this->db, 'FailedToGetActions');
     }
     $num = count($listofactions);
     if ($num || $forceshowtitle) {
         if ($typeelement == 'invoice') {
             $title = $langs->trans('ActionsOnBill');
         } elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') {
             $title = $langs->trans('ActionsOnBill');
         } elseif ($typeelement == 'propal') {
             $title = $langs->trans('ActionsOnPropal');
         } elseif ($typeelement == 'order') {
             $title = $langs->trans('ActionsOnOrder');
         } elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') {
             $title = $langs->trans('ActionsOnOrder');
         } elseif ($typeelement == 'project') {
             $title = $langs->trans('ActionsOnProject');
         } elseif ($typeelement == 'shipping') {
             $title = $langs->trans('ActionsOnShipping');
         } elseif ($typeelement == 'fichinter') {
             $title = $langs->trans('ActionsOnFicheInter');
         } else {
             $title = $langs->trans("Actions");
         }
         print_titre($title);
         $total = 0;
         $var = true;
         print '<table class="noborder" width="100%">';
         print '<tr class="liste_titre">';
         print '<th class="liste_titre">' . $langs->trans('Ref') . '</th>';
         print '<th class="liste_titre">' . $langs->trans('Action') . '</th>';
         print '<th class="liste_titre">' . $langs->trans('Date') . '</th>';
         print '<th class="liste_titre">' . $langs->trans('By') . '</th>';
         print '</tr>';
         print "\n";
         $userstatic = new User($this->db);
         foreach ($listofactions as $action) {
             $savlabel = $action->label;
             $action->label = $action->ref;
             $ref = $action->getNomUrl(1);
             $action->label = $savlabel;
             $label = $action->getNomUrl(0, 38);
             $var = !$var;
             print '<tr ' . $bc[$var] . '>';
             print '<td>' . $ref . '</td>';
             print '<td>' . $label . '</td>';
             print '<td>' . dol_print_date($action->datep, 'day') . '</td>';
             print '<td>';
             if (!empty($action->author->id)) {
                 $userstatic->id = $action->author->id;
                 $userstatic->firstname = $action->author->firstname;
                 $userstatic->lastname = $action->author->lastname;
                 print $userstatic->getNomUrl(1);
             }
             print '</td>';
             print '</tr>';
         }
         print '</table>';
     }
     return $num;
 }
 /**
  *  Show list of actions for element
  *
  *  @param	Object	$object			Object
  *  @param  string	$typeelement	'invoice','propal','order','invoice_supplier','order_supplier','fichinter'
  *	@param	int		$socid			socid of user
  *	@return	int						<0 if KO, >=0 if OK
  */
 function showactions($object, $typeelement, $socid = 0)
 {
     global $langs, $conf, $user;
     global $bc;
     require_once DOL_DOCUMENT_ROOT . "/comm/action/class/actioncomm.class.php";
     $actioncomm = new ActionComm($this->db);
     $actioncomm->getActions($socid, $object->id, $typeelement);
     $num = count($actioncomm->actions);
     if ($num) {
         if ($typeelement == 'invoice') {
             $title = $langs->trans('ActionsOnBill');
         } elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') {
             $title = $langs->trans('ActionsOnBill');
         } elseif ($typeelement == 'propal') {
             $title = $langs->trans('ActionsOnPropal');
         } elseif ($typeelement == 'order') {
             $title = $langs->trans('ActionsOnOrder');
         } elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') {
             $title = $langs->trans('ActionsOnOrder');
         } elseif ($typeelement == 'project') {
             $title = $langs->trans('ActionsOnProject');
         } elseif ($typeelement == 'shipping') {
             $title = $langs->trans('ActionsOnShipping');
         } elseif ($typeelement == 'fichinter') {
             $title = $langs->trans('ActionsOnFicheInter');
         } else {
             $title = $langs->trans("Actions");
         }
         print_titre($title);
         $total = 0;
         $var = true;
         print '<table class="noborder" width="100%">';
         print '<tr class="liste_titre"><th class="liste_titre">' . $langs->trans('Ref') . '</th><th class="liste_titre">' . $langs->trans('Date') . '</th><th class="liste_titre">' . $langs->trans('Action') . '</th><th class="liste_titre">' . $langs->trans('By') . '</th></tr>';
         print "\n";
         foreach ($actioncomm->actions as $action) {
             $var = !$var;
             print '<tr ' . $bc[$var] . '>';
             print '<td>' . $action->getNomUrl(1) . '</td>';
             print '<td>' . dol_print_date($action->datep, 'day') . '</td>';
             print '<td title="' . dol_escape_htmltag($action->label) . '">' . dol_trunc($action->label, 32) . '</td>';
             $userstatic = new User($this->db);
             $userstatic->id = $action->author->id;
             $userstatic->firstname = $action->author->firstname;
             $userstatic->lastname = $action->author->lastname;
             print '<td>' . $userstatic->getNomUrl(1) . '</td>';
             print '</tr>';
         }
         print '</table>';
     }
     return $num;
 }
 /**
  *  Show list of actions for element
  *
  *  @param	Object	$object			Object
  *  @param  string	$typeelement	'invoice','propal','order','invoice_supplier','order_supplier','fichinter'
  *	@param	int		$socid			socid of user
  *  @param	int		$forceshowtitle	Show title even if there is no actions to show
  *	@return	int						<0 if KO, >=0 if OK
  */
 function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0)
 {
     global $langs, $conf, $user;
     global $bc;
     require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
     $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement);
     if (!is_array($listofactions)) {
         dol_print_error($this->db, 'FailedToGetActions');
     }
     $num = count($listofactions);
     if ($num || $forceshowtitle) {
         if ($typeelement == 'invoice') {
             $title = $langs->trans('ActionsOnBill');
         } elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') {
             $title = $langs->trans('ActionsOnBill');
         } elseif ($typeelement == 'propal') {
             $title = $langs->trans('ActionsOnPropal');
         } elseif ($typeelement == 'supplier_proposal') {
             $title = $langs->trans('ActionsOnSupplierProposal');
         } elseif ($typeelement == 'order') {
             $title = $langs->trans('ActionsOnOrder');
         } elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') {
             $title = $langs->trans('ActionsOnOrder');
         } elseif ($typeelement == 'project') {
             $title = $langs->trans('ActionsOnProject');
         } elseif ($typeelement == 'shipping') {
             $title = $langs->trans('ActionsOnShipping');
         } elseif ($typeelement == 'fichinter') {
             $title = $langs->trans('ActionsOnFicheInter');
         } else {
             $title = $langs->trans("Actions");
         }
         print load_fiche_titre($title, '', '');
         $total = 0;
         $var = true;
         print '<table class="noborder" width="100%">';
         print '<tr class="liste_titre">';
         print '<th class="liste_titre">' . $langs->trans('Ref') . '</th>';
         print '<th class="liste_titre">' . $langs->trans('Action') . '</th>';
         print '<th class="liste_titre">' . $langs->trans('Date') . '</th>';
         print '<th class="liste_titre">' . $langs->trans('By') . '</th>';
         print '<th class="liste_titre" align="right">' . $langs->trans('Status') . '</th>';
         print '</tr>';
         print "\n";
         $userstatic = new User($this->db);
         foreach ($listofactions as $action) {
             $ref = $action->getNomUrl(1, -1);
             $label = $action->getNomUrl(0, 38);
             $var = !$var;
             print '<tr ' . $bc[$var] . '>';
             print '<td>' . $ref . '</td>';
             print '<td>' . $label . '</td>';
             print '<td>' . dol_print_date($action->datep, 'dayhour');
             if ($action->datef) {
                 $tmpa = dol_getdate($action->datep);
                 $tmpb = dol_getdate($action->datef);
                 if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
                     if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) {
                         print '-' . dol_print_date($action->datef, 'hour');
                     }
                 } else {
                     print '-' . dol_print_date($action->datef, 'dayhour');
                 }
             }
             print '</td>';
             print '<td>';
             if (!empty($action->author->id)) {
                 $userstatic->id = $action->author->id;
                 $userstatic->firstname = $action->author->firstname;
                 $userstatic->lastname = $action->author->lastname;
                 print $userstatic->getNomUrl(1);
             }
             print '</td>';
             print '<td align="right">';
             if (!empty($action->author->id)) {
                 print $action->getLibStatut(3);
             }
             print '</td>';
             print '</tr>';
         }
         print '</table>';
     }
     return $num;
 }
 /**
  *  Show list of actions for element
  *
  *  @param  Object  $object         Object
  *  @param  string  $typeelement    'agefodd_agsession'
  *  @param  int     $socid          socid of user
  *  @return int                     <0 if KO, >=0 if OK
  */
 function showactions($object, $typeelement = 'agefodd_agsession', $socid = 0)
 {
     global $langs, $conf, $user;
     global $bc;
     require_once DOL_DOCUMENT_ROOT . "/comm/action/class/actioncomm.class.php";
     $actioncomm = new ActionComm($this->db);
     $actioncomm->getActions($socid, $object->id, $typeelement);
     $num = count($actioncomm->actions);
     if ($num) {
         if ($typeelement == 'agefodd_agsession') {
             $title = $langs->trans('AgfActionsOnTraining');
         } else {
             $title = $langs->trans("Actions");
         }
         print_titre($title);
         $total = 0;
         $var = true;
         print '<table class="noborder" width="100%">';
         print '<tr class="liste_titre"><th class="liste_titre">' . $langs->trans('Ref') . '</th><th class="liste_titre">' . $langs->trans('Date') . '</th><th class="liste_titre">' . $langs->trans('Action') . '</th><th class="liste_titre">' . $langs->trans('ThirdParty') . '</th><th class="liste_titre">' . $langs->trans('By') . '</th></tr>';
         print "\n";
         foreach ($actioncomm->actions as $action) {
             $var = !$var;
             print '<tr ' . $bc[$var] . '>';
             print '<td>' . $action->getNomUrl(1) . '</td>';
             print '<td>' . dol_print_date($action->datep, 'dayhour') . '</td>';
             print '<td title="' . dol_escape_htmltag($action->label) . '">' . dol_trunc($action->label, 50) . '</td>';
             $userstatic = new User($this->db);
             $userstatic->id = $action->author->id;
             $userstatic->firstname = $action->author->firstname;
             $userstatic->lastname = $action->author->lastname;
             print '<td>' . $userstatic->getElementUrl($action->socid, 'societe', 1) . '</td>';
             print '<td>' . $userstatic->getNomUrl(1) . '</td>';
             print '</tr>';
         }
         print '</table>';
     }
     return $num;
 }