code syntax r... dir

This commit is contained in:
Frédéric FRANCE 2021-02-26 20:53:03 +01:00
parent 0d4acc53e2
commit 2137486e55
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
47 changed files with 3693 additions and 3164 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -70,12 +70,15 @@ class ReceptionStats extends Stats
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
$this->where .= " AND c.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($this->socid)
{
if (!$user->rights->societe->client->voir && !$this->socid) {
$this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($this->socid) {
$this->where .= " AND c.fk_soc = ".$this->socid;
}
if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid;
if ($this->userid > 0) {
$this->where .= ' AND c.fk_user_author = '.$this->userid;
}
}
/**
@ -114,7 +117,9 @@ class ReceptionStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
$sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');
@ -133,7 +138,9 @@ class ReceptionStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg";
$sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY year";
$sql .= $this->db->order('year', 'DESC');

View File

@ -44,17 +44,17 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'reception', $id, '');
$object = new Reception($db);
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
$object->fetch_thirdparty();
if (!empty($object->origin))
{
if (!empty($object->origin)) {
$origin = $object->origin;
$object->fetch_origin();
@ -62,8 +62,7 @@ if ($id > 0 || !empty($ref))
}
// Linked documents
if ($origin == 'order_supplier' && $object->$typeobject->id && !empty($conf->fournisseur->enabled))
{
if ($origin == 'order_supplier' && $object->$typeobject->id && !empty($conf->fournisseur->enabled)) {
$objectsrc = new CommandeFournisseur($db);
$objectsrc->fetch($object->$typeobject->id);
}
@ -74,22 +73,18 @@ if ($id > 0 || !empty($ref))
* Actions
*/
if ($action == 'addcontact' && $user->rights->reception->creer)
{
if ($result > 0 && $id > 0)
{
if ($action == 'addcontact' && $user->rights->reception->creer) {
if ($result > 0 && $id > 0) {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $objectsrc->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
}
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors");
$mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
} else {
@ -98,21 +93,14 @@ if ($action == 'addcontact' && $user->rights->reception->creer)
}
setEventMessages($mesg, $mesgs, 'errors');
}
}
// bascule du statut d'un contact
elseif ($action == 'swapstatut' && $user->rights->reception->creer)
{
} elseif ($action == 'swapstatut' && $user->rights->reception->creer) {
// bascule du statut d'un contact
$result = $objectsrc->swapContactStatus(GETPOST('ligne'));
}
// Efface un contact
elseif ($action == 'deletecontact' && $user->rights->reception->creer)
{
} elseif ($action == 'deletecontact' && $user->rights->reception->creer) {
// Efface un contact
$result = $objectsrc->delete_contact(GETPOST("lineid"));
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@ -147,8 +135,7 @@ $userstatic = new User($db);
/* */
/* *************************************************************************** */
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$langs->trans("OrderCard");
$head = reception_prepare_head($object);
@ -210,8 +197,7 @@ if ($id > 0 || !empty($ref))
print '<table class="border centpercent">';
// Linked documents
if ($origin == 'order_supplier' && $object->$typeobject->id && !empty($conf->fournisseur->enabled))
{
if ($origin == 'order_supplier' && $object->$typeobject->id && !empty($conf->fournisseur->enabled)) {
print '<tr><td class="titlefield">';
$objectsrc = new CommandeFournisseur($db);
$objectsrc->fetch($object->$typeobject->id);
@ -221,8 +207,7 @@ if ($id > 0 || !empty($ref))
print "</td>\n";
print '</tr>';
}
if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled))
{
if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
print '<tr><td class="titlefield">';
$objectsrc = new Propal($db);
$objectsrc->fetch($object->$typeobject->id);
@ -256,10 +241,11 @@ if ($id > 0 || !empty($ref))
// Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
foreach ($dirtpls as $reldir)
{
foreach ($dirtpls as $reldir) {
$res = @include dol_buildpath($reldir.'/contacts.tpl.php');
if ($res) break;
if ($res) {
break;
}
}
}

View File

@ -53,8 +53,7 @@ print load_fiche_titre($langs->trans("ReceptionsArea"), '', 'dollyrevert');
print '<div class="fichecenter"><div class="fichethirdleft">';
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
{
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
print '<form method="post" action="list.php">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<div class="div-table-responsive-no-min">';
@ -79,30 +78,28 @@ $sql .= " FROM ".MAIN_DB_PREFIX."reception as e";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception'";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (!$user->rights->societe->client->voir && !$socid)
{
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
$sql .= $clause." sc.fk_user = ".$user->id;
$clause = " AND ";
}
$sql .= $clause." e.fk_statut = 0";
$sql .= " AND e.entity IN (".getEntity('reception').")";
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
if ($socid) {
$sql .= " AND c.fk_soc = ".$socid;
}
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("ReceptionsToValidate").'</th></tr>';
$num = $db->num_rows($resql);
if ($num)
{
if ($num) {
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
$reception->id = $obj->rowid;
@ -116,7 +113,9 @@ if ($resql)
print '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name.'</a>';
print '</td>';
print '<td>';
if ($obj->commande_fournisseur_id) print '<a href="'.DOL_URL_ROOT.'/commande_fournisseur/card.php?id='.$obj->commande_fournisseur_id.'">'.$obj->commande_fournisseur_ref.'</a>';
if ($obj->commande_fournisseur_id) {
print '<a href="'.DOL_URL_ROOT.'/commande_fournisseur/card.php?id='.$obj->commande_fournisseur_id.'">'.$obj->commande_fournisseur_ref.'</a>';
}
print '</td></tr>';
$i++;
}
@ -144,27 +143,30 @@ $sql .= " FROM ".MAIN_DB_PREFIX."reception as e";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception' AND el.sourcetype IN ('order_supplier')";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid AND el.sourcetype IN ('order_supplier') AND el.targettype = 'reception'";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
}
$sql .= " WHERE e.entity IN (".getEntity('reception').")";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND sc.fk_user = ".$user->id;
}
$sql .= " AND e.fk_statut = 1";
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
if ($socid) {
$sql .= " AND c.fk_soc = ".$socid;
}
$sql .= " ORDER BY e.date_delivery DESC";
$sql .= $db->plimit($max, 0);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
if ($num)
{
if ($num) {
$i = 0;
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("LastReceptions", $num).'</th></tr>';
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
$reception->id = $obj->rowid;
@ -176,19 +178,22 @@ if ($resql)
print '</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.'</a></td>';
print '<td>';
if ($obj->commande_fournisseur_id > 0)
{
if ($obj->commande_fournisseur_id > 0) {
$orderstatic->id = $obj->commande_fournisseur_id;
$orderstatic->ref = $obj->commande_fournisseur_ref;
print $orderstatic->getNomUrl(1);
} else print '&nbsp;';
} else {
print '&nbsp;';
}
print '</td></tr>';
$i++;
}
print "</table></div><br>";
}
$db->free($resql);
} else dol_print_error($db);
} else {
dol_print_error($db);
}
@ -199,19 +204,23 @@ if ($resql)
$sql = "SELECT c.rowid, c.ref, c.ref_supplier as ref_supplier, c.fk_statut as status, c.billed as billed, s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c,";
$sql .= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('supplier_order').")";
$sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.")";
if ($socid > 0) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid > 0) {
$sql .= " AND c.fk_soc = ".$socid;
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
$sql .= " ORDER BY c.rowid ASC";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
if ($num)
{
if ($num) {
$langs->load("orders");
$i = 0;
@ -219,8 +228,7 @@ if ($resql)
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("SuppliersOrdersToProcess").' <span class="badge">'.$num.'</span></th></tr>';
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
$orderstatic->id = $obj->rowid;

View File

@ -42,7 +42,9 @@ $toselect = GETPOST('toselect', 'array');
// Security check
$receptionid = GETPOST('id', 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'reception', $receptionid, '');
$diroutputmassaction = $conf->reception->dir_output.'/temp/massgeneration/'.$user->id;
@ -64,9 +66,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (!$sortfield) $sortfield = "e.ref";
if (!$sortorder) $sortorder = "DESC";
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (!$sortfield) {
$sortfield = "e.ref";
}
if (!$sortorder) {
$sortorder = "DESC";
}
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -92,7 +100,9 @@ $fieldstosearchall = array(
's.nom'=>"ThirdParty",
'e.note_public'=>'NotePublic',
);
if (empty($user->socid)) $fieldstosearchall["e.note_private"] = "NotePrivate";
if (empty($user->socid)) {
$fieldstosearchall["e.note_private"] = "NotePrivate";
}
$checkedtypetiers = 0;
$arrayfields = array(
@ -122,18 +132,23 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
* Actions
*/
if (GETPOST('cancel')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction') && $massaction != 'confirm_createbills') { $massaction = ''; }
if (GETPOST('cancel')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction') && $massaction != 'confirm_createbills') {
$massaction = '';
}
$parameters = array('socid'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$search_ref_supplier = '';
$search_ref_rcp = '';
$search_ref_liv = '';
@ -148,8 +163,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_array_options = array();
}
if (empty($reshook))
{
if (empty($reshook)) {
if ($massaction == 'confirm_createbills') {
$receptions = GETPOST('toselect', 'array');
$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
@ -162,8 +176,7 @@ if (empty($reshook))
$db->begin();
$errors = array();
foreach ($receptions as $id_reception)
{
foreach ($receptions as $id_reception) {
$rcp = new Reception($db);
// On ne facture que les réceptions validées
if ($rcp->fetch($id_reception) <= 0 || $rcp->statut != 1) {
@ -175,16 +188,19 @@ if (empty($reshook))
$object = new FactureFournisseur($db);
if (!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])) {
$object = $TFactThird[$rcp->socid]; // If option "one bill per third" is set, we use already created reception.
if (empty($object->rowid) && $object->id != null)$object->rowid = $object->id;
if (!empty($object->rowid))$object->fetchObjectLinked();
if (empty($object->rowid) && $object->id != null) {
$object->rowid = $object->id;
}
if (!empty($object->rowid)) {
$object->fetchObjectLinked();
}
$rcp->fetchObjectLinked();
if (count($rcp->linkedObjectsIds['reception']) > 0)
{
foreach ($rcp->linkedObjectsIds['reception'] as $key => $value)
{
if (empty($object->linkedObjectsIds['reception']) || !in_array($value, $object->linkedObjectsIds['reception']))//Dont try to link if already linked
if (count($rcp->linkedObjectsIds['reception']) > 0) {
foreach ($rcp->linkedObjectsIds['reception'] as $key => $value) {
if (empty($object->linkedObjectsIds['reception']) || !in_array($value, $object->linkedObjectsIds['reception'])) { //Dont try to link if already linked
$object->add_object_linked('reception', $value); // add supplier order linked object
}
}
}
} else {
@ -200,8 +216,7 @@ if (empty($reshook))
$object->ref_supplier = $rcp->ref_supplier;
$datefacture = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
if (empty($datefacture))
{
if (empty($datefacture)) {
$datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y"));
}
@ -210,10 +225,8 @@ if (empty($reshook))
$object->origin_id = $id_reception;
$rcp->fetchObjectLinked();
if (count($rcp->linkedObjectsIds['reception']) > 0)
{
foreach ($rcp->linkedObjectsIds['reception'] as $key => $value)
{
if (count($rcp->linkedObjectsIds['reception']) > 0) {
foreach ($rcp->linkedObjectsIds['reception'] as $key => $value) {
$object->linked_objects['reception'] = $value;
}
}
@ -229,23 +242,19 @@ if (empty($reshook))
}
}
if ($object->id > 0)
{
if ($object->id > 0) {
if (!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])) { //cause function create already add object linked for facturefournisseur
$res = $object->add_object_linked($object->origin, $id_reception);
if ($res == 0)
{
if ($res == 0) {
$errors[] = $object->error;
$error++;
}
}
if (!$error)
{
if (!$error) {
$lines = $rcp->lines;
if (empty($lines) && method_exists($rcp, 'fetch_lines'))
{
if (empty($lines) && method_exists($rcp, 'fetch_lines')) {
$rcp->fetch_lines();
$lines = $rcp->lines;
}
@ -253,11 +262,9 @@ if (empty($reshook))
$fk_parent_line = 0;
$num = count($lines);
for ($i = 0; $i < $num; $i++)
{
for ($i = 0; $i < $num; $i++) {
$desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
if ($lines[$i]->subprice < 0)
{
if ($lines[$i]->subprice < 0) {
// Negative line, we create a discount line
$discount = new DiscountAbsolute($db);
$discount->fk_soc = $object->socid;
@ -268,8 +275,7 @@ if (empty($reshook))
$discount->fk_user = $user->id;
$discount->description = $desc;
$discountid = $discount->create($user);
if ($discountid > 0)
{
if ($discountid > 0) {
$result = $object->insert_discount($discountid);
//$result=$discount->link_to_invoice($lineid,$id);
} else {
@ -282,17 +288,28 @@ if (empty($reshook))
$product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
// Date start
$date_start = false;
if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue;
if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel;
if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start;
if ($lines[$i]->date_debut_prevue) {
$date_start = $lines[$i]->date_debut_prevue;
}
if ($lines[$i]->date_debut_reel) {
$date_start = $lines[$i]->date_debut_reel;
}
if ($lines[$i]->date_start) {
$date_start = $lines[$i]->date_start;
}
//Date end
$date_end = false;
if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue;
if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel;
if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end;
if ($lines[$i]->date_fin_prevue) {
$date_end = $lines[$i]->date_fin_prevue;
}
if ($lines[$i]->date_fin_reel) {
$date_end = $lines[$i]->date_fin_reel;
}
if ($lines[$i]->date_end) {
$date_end = $lines[$i]->date_end;
}
// Reset fk_parent_line for no child products and special product
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
{
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
$fk_parent_line = 0;
}
$result = $object->addline(
@ -321,8 +338,7 @@ if (empty($reshook))
$rcp->add_object_linked('facture_fourn_det', $result);
if ($result > 0)
{
if ($result > 0) {
$lineid = $result;
} else {
$lineid = 0;
@ -330,8 +346,7 @@ if (empty($reshook))
break;
}
// Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9)
{
if ($result > 0 && $lines[$i]->product_type == 9) {
$fk_parent_line = $result;
}
}
@ -341,22 +356,22 @@ if (empty($reshook))
//$rcp->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
if (!empty($createbills_onebythird) && empty($TFactThird[$rcp->socid])) $TFactThird[$rcp->socid] = $object;
else $TFact[$object->id] = $object;
if (!empty($createbills_onebythird) && empty($TFactThird[$rcp->socid])) {
$TFactThird[$rcp->socid] = $object;
} else {
$TFact[$object->id] = $object;
}
}
// Build doc with all invoices
$TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
$toselect = array();
if (!$error && $validate_invoices)
{
if (!$error && $validate_invoices) {
$massaction = $action = 'builddoc';
foreach ($TAllFact as &$object)
{
foreach ($TAllFact as &$object) {
$result = $object->validate($user);
if ($result <= 0)
{
if ($result <= 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
break;
@ -374,8 +389,7 @@ if (empty($reshook))
$massaction = $action = 'confirm_createbills';
}
if (!$error)
{
if (!$error) {
$db->commit();
setEventMessage($langs->trans('BillCreated', $nb_bills_created));
} else {
@ -411,60 +425,85 @@ $sql .= " state.code_departement as state_code, state.nom as state_name,";
$sql .= ' e.date_creation as date_creation, e.tms as date_update';
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
}
}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."reception as e";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)";
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'reception' AND ee.targettype = 'delivery'";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.rowid = ee.fk_target";
if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all
{
if (!$user->rights->societe->client->voir && !$socid) { // Internal user with no permission to see all
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE e.entity IN (".getEntity('reception').")";
if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all
{
if (!$user->rights->societe->client->voir && !$socid) { // Internal user with no permission to see all
$sql .= " AND e.fk_soc = sc.fk_soc";
$sql .= " AND sc.fk_user = ".$user->id;
}
if ($socid)
{
if ($socid) {
$sql .= " AND e.fk_soc = ".$socid;
}
if ($search_status <> '' && $search_status >= 0) {
$sql .= " AND e.fk_statut = ".$search_status;
}
if ($search_billed != '' && $search_billed >= 0) $sql .= ' AND e.billed = '.$search_billed;
if ($search_town) $sql .= natural_search('s.town', $search_town);
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
if ($search_state) $sql .= natural_search("state.nom", $search_state);
if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
if ($search_ref_rcp) $sql .= natural_search('e.ref', $search_ref_rcp);
if ($search_ref_liv) $sql .= natural_search('l.ref', $search_ref_liv);
if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($search_ref_supplier) $sql .= natural_search('e.ref_supplier', $search_ref_supplier);
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
if ($search_billed != '' && $search_billed >= 0) {
$sql .= ' AND e.billed = '.$search_billed;
}
if ($search_town) {
$sql .= natural_search('s.town', $search_town);
}
if ($search_zip) {
$sql .= natural_search("s.zip", $search_zip);
}
if ($search_state) {
$sql .= natural_search("state.nom", $search_state);
}
if ($search_country) {
$sql .= " AND s.fk_pays IN (".$search_country.')';
}
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
$sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
}
if ($search_ref_rcp) {
$sql .= natural_search('e.ref', $search_ref_rcp);
}
if ($search_ref_liv) {
$sql .= natural_search('l.ref', $search_ref_liv);
}
if ($search_company) {
$sql .= natural_search('s.nom', $search_company);
}
if ($search_ref_supplier) {
$sql .= natural_search('e.ref_supplier', $search_ref_supplier);
}
if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
}
// Add where from extra fields
foreach ($search_array_options as $key => $val)
{
foreach ($search_array_options as $key => $val) {
$crit = $val;
$tmpkey = preg_replace('/search_options_/', '', $key);
$typ = $extrafields->attributes[$object->table_element]['type'][$tmpkey];
$mode = 0;
if (in_array($typ, array('int', 'double', 'real'))) $mode = 1; // Search on a numeric
if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode = 2; // Search on a foreign key int
if ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0'))
{
if (in_array($typ, array('int', 'double', 'real'))) {
$mode = 1; // Search on a numeric
}
if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') {
$mode = 2; // Search on a foreign key int
}
if ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0')) {
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
}
}
@ -474,8 +513,7 @@ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // No
$sql .= $hookmanager->resPrint;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
@ -485,8 +523,7 @@ $sql .= $db->plimit($limit + 1, $offset);
//print $sql;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$reception = new Reception($db);
@ -494,27 +531,58 @@ if ($resql)
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($sall) $param .= "&amp;sall=".urlencode($sall);
if ($search_ref_rcp) $param .= "&amp;search_ref_rcp=".urlencode($search_ref_rcp);
if ($search_ref_liv) $param .= "&amp;search_ref_liv=".urlencode($search_ref_liv);
if ($search_company) $param .= "&amp;search_company=".urlencode($search_company);
if ($optioncss != '') $param .= '&amp;optioncss='.urlencode($optioncss);
if ($search_billed != '' && $search_billed >= 0) $param .= "&amp;search_billed=".urlencode($search_billed);
if ($search_town) $param .= "&amp;search_town=".urlencode($search_town);
if ($search_zip) $param .= "&amp;search_zip=".urlencode($search_zip);
if ($search_state) $param .= "&amp;search_state=".urlencode($search_state);
if ($search_status != '') $param .= "&amp;search_status=".urlencode($search_status);
if ($search_country) $param .= "&amp;search_country=".urlencode($search_country);
if ($search_type_thirdparty) $param .= "&amp;search_type_thirdparty=".urlencode($search_type_thirdparty);
if ($search_ref_supplier) $param .= "&amp;search_ref_supplier=".urlencode($search_ref_supplier);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($sall) {
$param .= "&amp;sall=".urlencode($sall);
}
if ($search_ref_rcp) {
$param .= "&amp;search_ref_rcp=".urlencode($search_ref_rcp);
}
if ($search_ref_liv) {
$param .= "&amp;search_ref_liv=".urlencode($search_ref_liv);
}
if ($search_company) {
$param .= "&amp;search_company=".urlencode($search_company);
}
if ($optioncss != '') {
$param .= '&amp;optioncss='.urlencode($optioncss);
}
if ($search_billed != '' && $search_billed >= 0) {
$param .= "&amp;search_billed=".urlencode($search_billed);
}
if ($search_town) {
$param .= "&amp;search_town=".urlencode($search_town);
}
if ($search_zip) {
$param .= "&amp;search_zip=".urlencode($search_zip);
}
if ($search_state) {
$param .= "&amp;search_state=".urlencode($search_state);
}
if ($search_status != '') {
$param .= "&amp;search_status=".urlencode($search_status);
}
if ($search_country) {
$param .= "&amp;search_country=".urlencode($search_country);
}
if ($search_type_thirdparty) {
$param .= "&amp;search_type_thirdparty=".urlencode($search_type_thirdparty);
}
if ($search_ref_supplier) {
$param .= "&amp;search_ref_supplier=".urlencode($search_ref_supplier);
}
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
foreach ($search_array_options as $key => $val) {
$crit = $val;
$tmpkey = preg_replace('/search_options_/', '', $key);
if ($val != '') $param .= '&search_options_'.$tmpkey.'='.urlencode($val);
if ($val != '') {
$param .= '&search_options_'.$tmpkey.'='.urlencode($val);
}
}
@ -522,14 +590,20 @@ if ($resql)
// 'presend'=>$langs->trans("SendByMail"),
);
if ($user->rights->fournisseur->facture->creer)$arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier");
if ($massaction == 'createbills') $arrayofmassactions = array();
if ($user->rights->fournisseur->facture->creer) {
$arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier");
}
if ($massaction == 'createbills') {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
$i = 0;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -539,8 +613,7 @@ if ($resql)
print_barre_liste($langs->trans('ListOfReceptions'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dollyrevert', 0, '', '', $limit, 0, 0, 1);
if ($massaction == 'createbills')
{
if ($massaction == 'createbills') {
//var_dump($_REQUEST);
print '<input type="hidden" name="massaction" value="confirm_createbills">';
@ -566,8 +639,7 @@ if ($resql)
print $langs->trans('ValidateInvoices');
print '</td>';
print '<td>';
if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL))
{
if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
print $form->selectyesno('validate_invoices', 0, 1, 1);
print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')';
} else {
@ -585,15 +657,15 @@ if ($resql)
print '<br>';
}
if ($sall)
{
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
if ($sall) {
foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val);
}
print $langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall);
}
$moreforfilter = '';
if (!empty($moreforfilter))
{
if (!empty($moreforfilter)) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
$parameters = array('type'=>$type);
@ -614,65 +686,60 @@ if ($resql)
// --------------------------------------------------------------------
print '<tr class="liste_titre_filter">';
// Ref
if (!empty($arrayfields['e.ref']['checked']))
{
if (!empty($arrayfields['e.ref']['checked'])) {
print '<td class="liste_titre">';
print '<input class="flat" size="6" type="text" name="search_ref_rcp" value="'.$search_ref_rcp.'">';
print '</td>';
}
// Ref customer
if (!empty($arrayfields['e.ref_supplier']['checked']))
{
if (!empty($arrayfields['e.ref_supplier']['checked'])) {
print '<td class="liste_titre">';
print '<input class="flat" size="6" type="text" name="search_ref_supplier" value="'.$search_ref_supplier.'">';
print '</td>';
}
// Thirdparty
if (!empty($arrayfields['s.nom']['checked']))
{
if (!empty($arrayfields['s.nom']['checked'])) {
print '<td class="liste_titre left">';
print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
print '</td>';
}
// Town
if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
if (!empty($arrayfields['s.town']['checked'])) {
print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
}
// Zip
if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
if (!empty($arrayfields['s.zip']['checked'])) {
print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
}
// State
if (!empty($arrayfields['state.nom']['checked']))
{
if (!empty($arrayfields['state.nom']['checked'])) {
print '<td class="liste_titre">';
print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
print '</td>';
}
// Country
if (!empty($arrayfields['country.code_iso']['checked']))
{
if (!empty($arrayfields['country.code_iso']['checked'])) {
print '<td class="liste_titre center">';
print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
print '</td>';
}
// Company type
if (!empty($arrayfields['typent.code']['checked']))
{
if (!empty($arrayfields['typent.code']['checked'])) {
print '<td class="liste_titre maxwidthonsmartphone center">';
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
print '</td>';
}
// Date delivery planned
if (!empty($arrayfields['e.date_delivery']['checked']))
{
if (!empty($arrayfields['e.date_delivery']['checked'])) {
print '<td class="liste_titre">&nbsp;</td>';
}
if (!empty($arrayfields['l.ref']['checked']))
{
if (!empty($arrayfields['l.ref']['checked'])) {
// Delivery ref
print '<td class="liste_titre">';
print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"';
print '</td>';
}
if (!empty($arrayfields['l.date_delivery']['checked']))
{
if (!empty($arrayfields['l.date_delivery']['checked'])) {
// Date received
print '<td class="liste_titre">&nbsp;</td>';
}
@ -684,27 +751,23 @@ if ($resql)
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (!empty($arrayfields['e.datec']['checked']))
{
if (!empty($arrayfields['e.datec']['checked'])) {
print '<td class="liste_titre">';
print '</td>';
}
// Date modification
if (!empty($arrayfields['e.tms']['checked']))
{
if (!empty($arrayfields['e.tms']['checked'])) {
print '<td class="liste_titre">';
print '</td>';
}
// Status
if (!empty($arrayfields['e.fk_statut']['checked']))
{
if (!empty($arrayfields['e.fk_statut']['checked'])) {
print '<td class="liste_titre maxwidthonsmartphone right">';
print $form->selectarray('search_status', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $search_status, 1);
print '</td>';
}
// Status billed
if (!empty($arrayfields['e.billed']['checked']))
{
if (!empty($arrayfields['e.billed']['checked'])) {
print '<td class="liste_titre maxwidthonsmartphone center">';
print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
print '</td>';
@ -717,34 +780,63 @@ if ($resql)
print "</tr>\n";
print '<tr class="liste_titre">';
if (!empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['e.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['e.ref_supplier']['label'], $_SERVER["PHP_SELF"], "e.ref_supplier", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left ');
if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['e.ref']['checked'])) {
print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['e.ref_supplier']['checked'])) {
print_liste_field_titre($arrayfields['e.ref_supplier']['label'], $_SERVER["PHP_SELF"], "e.ref_supplier", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['s.nom']['checked'])) {
print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left ');
}
if (!empty($arrayfields['s.town']['checked'])) {
print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['s.zip']['checked'])) {
print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['state.nom']['checked'])) {
print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['country.code_iso']['checked'])) {
print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['typent.code']['checked'])) {
print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['e.date_delivery']['checked'])) {
print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['l.ref']['checked'])) {
print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['l.date_delivery']['checked'])) {
print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (!empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (!empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['e.datec']['checked'])) {
print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
}
if (!empty($arrayfields['e.tms']['checked'])) {
print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
}
if (!empty($arrayfields['e.fk_statut']['checked'])) {
print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['e.billed']['checked'])) {
print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center ');
}
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
$reception->id = $obj->rowid;
@ -758,8 +850,7 @@ if ($resql)
print '<tr class="oddeven">';
// Ref
if (!empty($arrayfields['e.ref']['checked']))
{
if (!empty($arrayfields['e.ref']['checked'])) {
print "<td>";
print $reception->getNomUrl(1);
$filename = dol_sanitizeFileName($reception->ref);
@ -768,95 +859,104 @@ if ($resql)
print $formfile->getDocumentsLink($reception->element, $filename, $filedir);
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Ref customer
if (!empty($arrayfields['e.ref_supplier']['checked']))
{
if (!empty($arrayfields['e.ref_supplier']['checked'])) {
print "<td>";
print $obj->ref_supplier;
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Third party
if (!empty($arrayfields['s.nom']['checked']))
{
if (!empty($arrayfields['s.nom']['checked'])) {
print '<td>';
print $companystatic->getNomUrl(1);
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Town
if (!empty($arrayfields['s.town']['checked']))
{
if (!empty($arrayfields['s.town']['checked'])) {
print '<td class="nocellnopadd">';
print $obj->town;
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Zip
if (!empty($arrayfields['s.zip']['checked']))
{
if (!empty($arrayfields['s.zip']['checked'])) {
print '<td class="nocellnopadd">';
print $obj->zip;
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// State
if (!empty($arrayfields['state.nom']['checked']))
{
if (!empty($arrayfields['state.nom']['checked'])) {
print "<td>".$obj->state_name."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Country
if (!empty($arrayfields['country.code_iso']['checked']))
{
if (!empty($arrayfields['country.code_iso']['checked'])) {
print '<td class="center">';
$tmparray = getCountry($obj->fk_pays, 'all');
print $tmparray['label'];
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Type ent
if (!empty($arrayfields['typent.code']['checked']))
{
if (!empty($arrayfields['typent.code']['checked'])) {
print '<td class="center">';
if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1);
if (count($typenArray) == 0) {
$typenArray = $formcompany->typent_array(1);
}
print $typenArray[$obj->typent_code];
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Date delivery planed
if (!empty($arrayfields['e.date_delivery']['checked']))
{
if (!empty($arrayfields['e.date_delivery']['checked'])) {
print '<td class="center">';
print dol_print_date($db->jdate($obj->delivery_date), "day");
/*$now = time();
if ( ($now - $db->jdate($obj->date_reception)) > $conf->warnings->lim && $obj->statutid == 1 )
{
}*/
if ( ($now - $db->jdate($obj->date_reception)) > $conf->warnings->lim && $obj->statutid == 1 )
{
}*/
print "</td>\n";
}
if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked']))
{
if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) {
$reception->fetchObjectLinked($reception->id, $reception->element);
$receiving = '';
if (count($reception->linkedObjects['delivery']) > 0) $receiving = reset($reception->linkedObjects['delivery']);
if (count($reception->linkedObjects['delivery']) > 0) {
$receiving = reset($reception->linkedObjects['delivery']);
}
if (!empty($arrayfields['l.ref']['checked']))
{
if (!empty($arrayfields['l.ref']['checked'])) {
// Ref
print '<td>';
print !empty($receiving) ? $receiving->getNomUrl($db) : '';
print '</td>';
}
if (!empty($arrayfields['l.date_delivery']['checked']))
{
if (!empty($arrayfields['l.date_delivery']['checked'])) {
// Date received
print '<td class="center">';
print dol_print_date($db->jdate($obj->date_reception), "day");
@ -872,44 +972,51 @@ if ($resql)
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (!empty($arrayfields['e.datec']['checked']))
{
if (!empty($arrayfields['e.datec']['checked'])) {
print '<td class="center nowrap">';
print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Date modification
if (!empty($arrayfields['e.tms']['checked']))
{
if (!empty($arrayfields['e.tms']['checked'])) {
print '<td class="center nowrap">';
print dol_print_date($db->jdate($obj->date_update), 'dayhour');
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Status
if (!empty($arrayfields['e.fk_statut']['checked']))
{
if (!empty($arrayfields['e.fk_statut']['checked'])) {
print '<td class="right nowrap">'.$reception->LibStatut($obj->fk_statut, 5).'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Billed
if (!empty($arrayfields['e.billed']['checked']))
{
if (!empty($arrayfields['e.billed']['checked'])) {
print '<td class="center">'.yn($obj->billed).'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Action column
print '<td class="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
print "</tr>\n";

View File

@ -48,30 +48,28 @@ $action = GETPOST('action', 'aZ09');
// Security check
$socid = '';
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, $origin, $origin_id);
$object = new Reception($db);
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
$object->fetch_thirdparty();
if (!empty($object->origin))
{
if (!empty($object->origin)) {
$typeobject = $object->origin;
$origin = $object->origin;
$object->fetch_origin();
}
// Linked documents
if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled))
{
if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) {
$objectsrc = new Commande($db);
$objectsrc->fetch($object->$typeobject->id);
}
if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled))
{
if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
$objectsrc = new Propal($db);
$objectsrc->fetch($object->$typeobject->id);
}
@ -95,8 +93,7 @@ llxHeader('', 'Reception');
$form = new Form($db);
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$head = reception_prepare_head($object);
print dol_get_fiche_head($head, 'note', $langs->trans("Reception"), -1, 'dollyrevert');

View File

@ -35,8 +35,7 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$userid = GETPOST('userid', 'int');
$socid = GETPOST('socid', 'int');
// Security check
if ($user->socid > 0)
{
if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@ -74,8 +73,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
// $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->socid)
{
if (!$user->rights->societe->client->voir || $user->socid) {
$filenamenb = $dir.'/receptionsnbinyear-'.$user->id.'-'.$year.'.png';
} else {
$filenamenb = $dir.'/receptionsnbinyear-'.$year.'.png';
@ -83,12 +81,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px1->SetData($data);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
while ($i <= $endyear) {
$legend[] = $i;
$i++;
}
@ -114,36 +110,36 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
if (!$user->rights->societe->client->voir || $user->socid)
{
$filenameamount = $dir.'/receptionsamountinyear-'.$user->id.'-'.$year.'.png';
$filenameamount = $dir.'/receptionsamountinyear-'.$user->id.'-'.$year.'.png';
}
else
{
$filenameamount = $dir.'/receptionsamountinyear-'.$year.'.png';
$filenameamount = $dir.'/receptionsamountinyear-'.$year.'.png';
}
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (! $mesg)
{
$px2->SetData($data);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
$legend[]=$i;
$i++;
}
$px2->SetLegend($legend);
$px2->SetMaxValue($px2->GetCeilMaxValue());
$px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
$px2->SetWidth($WIDTH);
$px2->SetHeight($HEIGHT);
$px2->SetYLabel($langs->trans("AmountOfReceptions"));
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
$px2->mode='depth';
$px2->SetTitle($langs->trans("AmountOfReceptionsByMonthHT"));
$px2->SetData($data);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
$legend[]=$i;
$i++;
}
$px2->SetLegend($legend);
$px2->SetMaxValue($px2->GetCeilMaxValue());
$px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
$px2->SetWidth($WIDTH);
$px2->SetHeight($HEIGHT);
$px2->SetYLabel($langs->trans("AmountOfReceptions"));
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
$px2->mode='depth';
$px2->SetTitle($langs->trans("AmountOfReceptionsByMonthHT"));
$px2->draw($filenameamount,$fileurlamount);
$px2->draw($filenameamount,$fileurlamount);
}
*/
@ -152,36 +148,36 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
if (!$user->rights->societe->client->voir || $user->socid)
{
$filename_avg = $dir.'/receptionsaverage-'.$user->id.'-'.$year.'.png';
$filename_avg = $dir.'/receptionsaverage-'.$user->id.'-'.$year.'.png';
}
else
{
$filename_avg = $dir.'/receptionsaverage-'.$year.'.png';
$filename_avg = $dir.'/receptionsaverage-'.$year.'.png';
}
$px3 = new DolGraph();
$mesg = $px3->isGraphKo();
if (! $mesg)
{
$px3->SetData($data);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
$legend[]=$i;
$i++;
}
$px3->SetLegend($legend);
$px3->SetYLabel($langs->trans("AmountAverage"));
$px3->SetMaxValue($px3->GetCeilMaxValue());
$px3->SetMinValue($px3->GetFloorMinValue());
$px3->SetWidth($WIDTH);
$px3->SetHeight($HEIGHT);
$px3->SetShading(3);
$px3->SetHorizTickIncrement(1);
$px3->mode='depth';
$px3->SetTitle($langs->trans("AmountAverage"));
$px3->SetData($data);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
$legend[]=$i;
$i++;
}
$px3->SetLegend($legend);
$px3->SetYLabel($langs->trans("AmountAverage"));
$px3->SetMaxValue($px3->GetCeilMaxValue());
$px3->SetMinValue($px3->GetFloorMinValue());
$px3->SetWidth($WIDTH);
$px3->SetHeight($HEIGHT);
$px3->SetShading(3);
$px3->SetHorizTickIncrement(1);
$px3->mode='depth';
$px3->SetTitle($langs->trans("AmountAverage"));
$px3->draw($filename_avg,$fileurl_avg);
$px3->draw($filename_avg,$fileurl_avg);
}
*/
@ -194,7 +190,9 @@ foreach ($data as $val) {
$arrayyears[$val['year']] = $val['year'];
}
}
if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
if (!count($arrayyears)) {
$arrayyears[$nowyear] = $nowyear;
}
$h = 0;
$head = array();
@ -231,8 +229,12 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
print '</td></tr>';
// Year
print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">';
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
if (!in_array($year, $arrayyears)) {
$arrayyears[$year] = $year;
}
if (!in_array($nowyear, $arrayyears)) {
$arrayyears[$nowyear] = $nowyear;
}
arsort($arrayyears);
print $form->selectarray('year', $arrayyears, $year, 0);
print '</td></tr>';
@ -251,11 +253,9 @@ print '<td class="center">'.$langs->trans("AmountAverage").'</td>';*/
print '</tr>';
$oldyear = 0;
foreach ($data as $val)
{
foreach ($data as $val) {
$year = $val['year'];
while (!empty($year) && $oldyear > $year + 1)
{ // If we have empty year
while (!empty($year) && $oldyear > $year + 1) { // If we have empty year
$oldyear--;
@ -270,8 +270,11 @@ foreach ($data as $val)
print '<tr class="oddeven" height="24">';
print '<td class="center">';
if ($year) print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'">'.$year.'</a>';
else print $langs->trans("ValidationDateNotDefinedEvenIfReceptionValidated");
if ($year) {
print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'">'.$year.'</a>';
} else {
print $langs->trans("ValidationDateNotDefinedEvenIfReceptionValidated");
}
print '</td>';
print '<td class="right">'.$val['nb'].'</td>';
/*print '<td class="right">'.price(price2num($val['total'],'MT'),1).'</td>';
@ -288,12 +291,14 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Show graphs
print '<table class="border centpercent"><tr valign="top"><td class="center">';
if ($mesg) { print $mesg; } else {
if ($mesg) {
print $mesg;
} else {
print $px1->show();
print "<br>\n";
/*print $px2->show();
print "<br>\n";
print $px3->show();*/
print "<br>\n";
print $px3->show();*/
}
print '</td></tr></table>';
@ -320,17 +325,17 @@ $sql.= " GROUP BY dm DESC";
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$nbproduct = $row[0];
$year = $row[1];
print "<tr>";
print '<td class="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td class="center">'.$nbproduct.'</td></tr>';
$i++;
}
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$nbproduct = $row[0];
$year = $row[1];
print "<tr>";
print '<td class="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td class="center">'.$nbproduct.'</td></tr>';
$i++;
}
}
$db->free($resql);

View File

@ -53,8 +53,7 @@ $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstats&file=reception
$px = new DolGraph();
$mesg = $px->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px->SetData($data);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetWidth($WIDTH);

View File

@ -18,8 +18,7 @@
*/
// Protection to avoid direct call of template
if (empty($conf) || !is_object($conf))
{
if (empty($conf) || !is_object($conf)) {
print "Error, template page can't be called as URL";
exit;
}
@ -42,52 +41,54 @@ $langs->load("receptions");
$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
$total = 0; $ilink = 0;
foreach ($linkedObjectBlock as $key => $objectlink)
{
foreach ($linkedObjectBlock as $key => $objectlink) {
$ilink++;
$trclass = 'oddeven';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
$trclass .= ' liste_sub_total';
}
?>
<tr class="<?php echo $trclass; ?>">
<td class="linkedcol-element"><?php echo $langs->trans("Reception"); ?>
<?php if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print '<a class="objectlinked_importbtn" href="'.$objectlink->getNomUrl(0, '', 0, 1).'&amp;action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a'; ?>
</td>
<td class="linkedcol-name nowraponall" ><?php echo $objectlink->getNomUrl(1); ?></td>
<td class="linkedcol-ref center"></td>
<td class="linkedcol-date center"><?php echo dol_print_date($objectlink->date_delivery, 'day'); ?></td>
<td class="linkedcol-amount right"><?php
<tr class="<?php echo $trclass; ?>">
<td class="linkedcol-element"><?php echo $langs->trans("Reception"); ?>
<?php if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
print '<a class="objectlinked_importbtn" href="'.$objectlink->getNomUrl(0, '', 0, 1).'&amp;action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a';
} ?>
</td>
<td class="linkedcol-name nowraponall" ><?php echo $objectlink->getNomUrl(1); ?></td>
<td class="linkedcol-ref center"></td>
<td class="linkedcol-date center"><?php echo dol_print_date($objectlink->date_delivery, 'day'); ?></td>
<td class="linkedcol-amount right"><?php
if ($user->rights->reception->lire) {
$total = $total + $objectlink->total_ht;
echo price($objectlink->total_ht);
} ?></td>
<td class="linkedcol-statut right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td class="linkedcol-action right">
<?php
<td class="linkedcol-statut right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td class="linkedcol-action right">
<?php
// For now, receptions must stay linked to order, so link is not deletable
if ($object->element != 'order_supplier') {
?>
<a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a>
<?php
<a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a>
<?php
}
?>
</td>
</tr>
<?php
</td>
</tr>
<?php
}
if (count($linkedObjectBlock) > 1)
{
if (count($linkedObjectBlock) > 1) {
?>
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
<td><?php echo $langs->trans("Total"); ?></td>
<td></td>
<td class="center"></td>
<td class="center"></td>
<td class="right"><?php echo price($total); ?></td>
<td class="right"></td>
<td class="right"></td>
</tr>
<?php
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
<td><?php echo $langs->trans("Total"); ?></td>
<td></td>
<td class="center"></td>
<td class="center"></td>
<td class="right"><?php echo price($total); ?></td>
<td class="right"></td>
<td class="right"></td>
</tr>
<?php
}
?>

View File

@ -34,13 +34,17 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'recruitment_recruitmentcandidature';
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
/*
@ -73,8 +77,7 @@ print dol_get_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
@ -84,8 +87,7 @@ if ($action != 'create' && $action != 'edit')
/*
* Creation of an optional field
*/
if ($action == 'create')
{
if ($action == 'create') {
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
@ -95,8 +97,7 @@ if ($action == 'create')
/*
* Edition of an optional field
*/
if ($action == 'edit' && !empty($attrname))
{
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -34,13 +34,17 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'recruitment_recruitmentjobposition';
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
/*
@ -73,8 +77,7 @@ print dol_get_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
@ -84,8 +87,7 @@ if ($action != 'create' && $action != 'edit')
/*
* Creation of an optional field
*/
if ($action == 'create')
{
if ($action == 'create') {
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
@ -95,8 +97,7 @@ if ($action == 'create')
/*
* Edition of an optional field
*/
if ($action == 'edit' && !empty($attrname))
{
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -33,7 +33,9 @@ $langs->loadLangs(array("admin", "recruitment"));
$action = GETPOST('action', 'aZ09');
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$error = 0;
@ -43,8 +45,11 @@ $error = 0;
*/
if ($action == 'setRECRUITMENT_ENABLE_PUBLIC_INTERFACE') {
if (GETPOST('value')) dolibarr_set_const($db, 'RECRUITMENT_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity);
else dolibarr_set_const($db, 'RECRUITMENT_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity);
if (GETPOST('value')) {
dolibarr_set_const($db, 'RECRUITMENT_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity);
} else {
dolibarr_set_const($db, 'RECRUITMENT_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity);
}
}
if ($action == 'update') {
@ -52,9 +57,11 @@ if ($action == 'update') {
$res = dolibarr_set_const($db, "RECRUITMENT_ENABLE_PUBLIC_INTERFACE", $public, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++;
if (!($res > 0)) {
$error++;
}
if (!$error) {
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');

View File

@ -25,16 +25,30 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
global $langs, $user;
@ -47,7 +61,9 @@ require_once DOL_DOCUMENT_ROOT."/recruitment/class/recruitmentjobposition.class.
$langs->loadLangs(array("admin", "recruitment"));
// Access control
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
// Parameters
$action = GETPOST('action', 'aZ09');
@ -71,28 +87,28 @@ $setupnotempty = 0;
* Actions
*/
if ((float) DOL_VERSION >= 6)
{
if ((float) DOL_VERSION >= 6) {
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
}
if ($action == 'updateMask')
{
if ($action == 'updateMask') {
$maskconstorder = GETPOST('maskconstorder', 'alpha');
$maskorder = GETPOST('maskorder', 'alpha');
if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
if ($maskconstorder) {
$res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++;
if (!($res > 0)) {
$error++;
}
if (!$error)
{
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'specimen')
{
} elseif ($action == 'specimen') {
$modele = GETPOST('module', 'alpha');
$tmpobjectkey = GETPOST('object');
@ -102,25 +118,21 @@ if ($action == 'updateMask')
// Search template files
$file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
foreach ($dirmodels as $reldir) {
$file = dol_buildpath($reldir."core/modules/mymodule/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
if (file_exists($file))
{
if (file_exists($file)) {
$filefound = 1;
$classname = "pdf_".$modele;
break;
}
}
if ($filefound)
{
if ($filefound) {
require_once $file;
$module = new $classname($db);
if ($module->write_file($tmpobject, $langs) > 0)
{
if ($module->write_file($tmpobject, $langs) > 0) {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
return;
} else {
@ -131,10 +143,8 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
}
}
// Activate a model
elseif ($action == 'set') {
} elseif ($action == 'set') {
// Activate a model
$ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') {
$ret = delDocumentModel($value, $type);
@ -142,12 +152,12 @@ elseif ($action == 'set') {
$tmpobjectkey = GETPOST('object');
if (!empty($tmpobjectkey)) {
$constforval = 'RECRUITMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
if ($conf->global->$constforval == "$value") dolibarr_del_const($db, $constforval, $conf->entity);
if ($conf->global->$constforval == "$value") {
dolibarr_del_const($db, $constforval, $conf->entity);
}
}
}
}
elseif ($action == 'setmod') {
} elseif ($action == 'setmod') {
// TODO Check if numbering module chosen can be activated by calling method canBeActivated
$tmpobjectkey = GETPOST('object');
if (!empty($tmpobjectkey)) {
@ -155,10 +165,8 @@ elseif ($action == 'setmod') {
dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
}
}
// Set default model
elseif ($action == 'setdoc') {
} elseif ($action == 'setdoc') {
// Set default model
$tmpobjectkey = GETPOST('object');
if (!empty($tmpobjectkey)) {
$constforval = 'RECRUITMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
@ -208,8 +216,7 @@ print dol_get_fiche_head($head, 'settings', '', -1, '');
//echo '<span class="opacitymedium">'.$langs->trans("RecruitmentSetupPage").'</span><br><br>';
if ($action == 'edit')
{
if ($action == 'edit') {
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
@ -217,8 +224,7 @@ if ($action == 'edit')
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $key => $val)
{
foreach ($arrayofparameters as $key => $val) {
print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
print $form->textwithpicto($langs->trans($key), $tooltiphelp);
@ -233,13 +239,11 @@ if ($action == 'edit')
print '</form>';
print '<br>';
} else {
if (!empty($arrayofparameters))
{
if (!empty($arrayofparameters)) {
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $key => $val)
{
foreach ($arrayofparameters as $key => $val) {
$setupnotempty++;
print '<tr class="oddeven"><td>';
@ -282,30 +286,28 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/".$moduledir);
if (is_dir($dir))
{
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle)) !== false)
{
if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
$file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.'/'.$file.'.php';
$module = new $file($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled())
{
if ($module->isEnabled()) {
dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
@ -318,14 +320,16 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
} elseif ($tmp == 'NotConfigured') {
print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n";
print '<td class="center">';
$constforvar = 'RECRUITMENT_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $file)
{
if ($conf->global->$constforvar == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
@ -345,8 +349,9 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip .= $langs->trans($module->error).'<br>';
@ -387,8 +392,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
if ($resql) {
$i = 0;
$num_rows = $db->num_rows($resql);
while ($i < $num_rows)
{
while ($i < $num_rows) {
$array = $db->fetch_array($resql);
array_push($def, $array[0]);
$i++;
@ -410,31 +414,23 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach (array('', '/doc') as $valdir)
{
foreach ($dirmodels as $reldir) {
foreach (array('', '/doc') as $valdir) {
$realpath = $reldir."core/modules/".$moduledir.$valdir;
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle)) !== false)
{
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
$filelist[] = $file;
}
closedir($handle);
arsort($filelist);
foreach ($filelist as $file)
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
if (file_exists($dir.'/'.$file))
{
foreach ($filelist as $file) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (file_exists($dir.'/'.$file)) {
$name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12);
@ -442,21 +438,26 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
$module = new $classname($db);
$modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
$modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified)
{
if ($modulequalified) {
print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
if (method_exists($module, 'info')) {
print $module->info($langs);
} else {
print $module->description;
}
print '</td>';
// Active
if (in_array($name, $def))
{
if (in_array($name, $def)) {
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on');
@ -483,8 +484,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf')
{
if ($module->type == 'pdf') {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -499,8 +499,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Preview
print '<td class="center">';
if ($module->type == 'pdf')
{
if ($module->type == 'pdf') {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'generic').'</a>';
} else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic');

View File

@ -25,16 +25,30 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
global $langs, $user;
@ -47,7 +61,9 @@ require_once DOL_DOCUMENT_ROOT."/recruitment/class/recruitmentjobposition.class.
$langs->loadLangs(array("admin", "recruitment"));
// Access control
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
// Parameters
$action = GETPOST('action', 'aZ09');
@ -71,28 +87,28 @@ $setupnotempty = 0;
* Actions
*/
if ((float) DOL_VERSION >= 6)
{
if ((float) DOL_VERSION >= 6) {
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
}
if ($action == 'updateMask')
{
if ($action == 'updateMask') {
$maskconstorder = GETPOST('maskconstorder', 'alpha');
$maskorder = GETPOST('maskorder', 'alpha');
if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
if ($maskconstorder) {
$res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++;
if (!($res > 0)) {
$error++;
}
if (!$error)
{
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'specimen')
{
} elseif ($action == 'specimen') {
$modele = GETPOST('module', 'alpha');
$tmpobjectkey = GETPOST('object');
@ -102,25 +118,21 @@ if ($action == 'updateMask')
// Search template files
$file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
foreach ($dirmodels as $reldir) {
$file = dol_buildpath($reldir."core/modules/mymodule/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
if (file_exists($file))
{
if (file_exists($file)) {
$filefound = 1;
$classname = "pdf_".$modele;
break;
}
}
if ($filefound)
{
if ($filefound) {
require_once $file;
$module = new $classname($db);
if ($module->write_file($tmpobject, $langs) > 0)
{
if ($module->write_file($tmpobject, $langs) > 0) {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
return;
} else {
@ -131,10 +143,8 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
}
}
// Activate a model
elseif ($action == 'set') {
} elseif ($action == 'set') {
// Activate a model
$ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') {
$tmpobjectkey = GETPOST('object');
@ -142,11 +152,11 @@ elseif ($action == 'set') {
$ret = delDocumentModel($value, $type);
if ($ret > 0) {
$constforval = 'RECRUITMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
if ($conf->global->$constforval == "$value") dolibarr_del_const($db, $constforval, $conf->entity);
if ($conf->global->$constforval == "$value") {
dolibarr_del_const($db, $constforval, $conf->entity);
}
}
}
elseif ($action == 'setmod') {
} elseif ($action == 'setmod') {
// TODO Check if numbering module chosen can be activated by calling method canBeActivated
$tmpobjectkey = GETPOST('object');
if (!empty($tmpobjectkey)) {
@ -154,10 +164,8 @@ elseif ($action == 'setmod') {
dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
}
}
// Set default model
elseif ($action == 'setdoc') {
} elseif ($action == 'setdoc') {
// Set default model
$tmpobjectkey = GETPOST('object');
$constforval = 'RECRUITMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
@ -205,8 +213,7 @@ print dol_get_fiche_head($head, 'settings_candidatures', '', -1, '');
//echo '<span class="opacitymedium">'.$langs->trans("RecruitmentSetupPage").'</span><br><br>';
if ($action == 'edit')
{
if ($action == 'edit') {
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
@ -214,8 +221,7 @@ if ($action == 'edit')
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $key => $val)
{
foreach ($arrayofparameters as $key => $val) {
print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
print $form->textwithpicto($langs->trans($key), $tooltiphelp);
@ -230,13 +236,11 @@ if ($action == 'edit')
print '</form>';
print '<br>';
} else {
if (!empty($arrayofparameters))
{
if (!empty($arrayofparameters)) {
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $key => $val)
{
foreach ($arrayofparameters as $key => $val) {
$setupnotempty++;
print '<tr class="oddeven"><td>';
@ -279,19 +283,14 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/".$moduledir);
if (is_dir($dir))
{
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle)) !== false)
{
if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
$file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.'/'.$file.'.php';
@ -299,11 +298,14 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
$module = new $file($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled())
{
if ($module->isEnabled()) {
dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
@ -316,14 +318,16 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
} elseif ($tmp == 'NotConfigured') {
print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n";
print '<td class="center">';
$constforvar = 'RECRUITMENT_'.strtoupper($myTmpObjectKey).'_ADDON';
if ($conf->global->$constforvar == $file)
{
if ($conf->global->$constforvar == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
@ -343,8 +347,9 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip .= $langs->trans($module->error).'<br>';
@ -382,12 +387,10 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
$sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$i = 0;
$num_rows = $db->num_rows($resql);
while ($i < $num_rows)
{
while ($i < $num_rows) {
$array = $db->fetch_array($resql);
array_push($def, $array[0]);
$i++;
@ -409,31 +412,23 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach (array('', '/doc') as $valdir)
{
foreach ($dirmodels as $reldir) {
foreach (array('', '/doc') as $valdir) {
$realpath = $reldir."core/modules/".$moduledir.$valdir;
$dir = dol_buildpath($realpath);
if (is_dir($dir))
{
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle)) !== false)
{
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
$filelist[] = $file;
}
closedir($handle);
arsort($filelist);
foreach ($filelist as $file)
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
if (file_exists($dir.'/'.$file))
{
foreach ($filelist as $file) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (file_exists($dir.'/'.$file)) {
$name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12);
@ -441,21 +436,26 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
$module = new $classname($db);
$modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
$modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified)
{
if ($modulequalified) {
print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
if (method_exists($module, 'info')) {
print $module->info($langs);
} else {
print $module->description;
}
print '</td>';
// Active
if (in_array($name, $def))
{
if (in_array($name, $def)) {
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on');
@ -482,8 +482,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf')
{
if ($module->type == 'pdf') {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -498,8 +497,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Preview
print '<td class="center">';
if ($module->type == 'pdf')
{
if ($module->type == 'pdf') {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'generic').'</a>';
} else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic');

View File

@ -164,8 +164,12 @@ class RecruitmentCandidature extends CommonObject
$this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0;
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['rowid']['visible'] = 0;
}
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
// Example to show how to set values of fields definition dynamically
/*if ($user->rights->recruitment->recruitmentcandidature->read) {
@ -174,23 +178,17 @@ class RecruitmentCandidature extends CommonObject
}*/
// Unset fields that are disabled
foreach ($this->fields as $key => $val)
{
if (isset($val['enabled']) && empty($val['enabled']))
{
foreach ($this->fields as $key => $val) {
if (isset($val['enabled']) && empty($val['enabled'])) {
unset($this->fields[$key]);
}
}
// Translate some data of arrayofkeyval
if (is_object($langs))
{
foreach ($this->fields as $key => $val)
{
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval']))
{
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
if (is_object($langs)) {
foreach ($this->fields as $key => $val) {
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
foreach ($val['arrayofkeyval'] as $key2 => $val2) {
$this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
}
}
@ -230,7 +228,9 @@ class RecruitmentCandidature extends CommonObject
// Load source object
$result = $object->fetchCommon($fromid);
if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
if ($result > 0 && !empty($object->table_element_line)) {
$object->fetchLines();
}
// get lines so they will be clone
//foreach($this->lines as $line)
@ -242,22 +242,29 @@ class RecruitmentCandidature extends CommonObject
unset($object->import_key);
// Clear fields
if (property_exists($object, 'ref')) $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
if (property_exists($object, 'label')) $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
if (property_exists($object, 'status')) { $object->status = self::STATUS_DRAFT; }
if (property_exists($object, 'date_creation')) { $object->date_creation = dol_now(); }
if (property_exists($object, 'date_modification')) { $object->date_modification = null; }
if (property_exists($object, 'ref')) {
$object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
}
if (property_exists($object, 'label')) {
$object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
}
if (property_exists($object, 'status')) {
$object->status = self::STATUS_DRAFT;
}
if (property_exists($object, 'date_creation')) {
$object->date_creation = dol_now();
}
if (property_exists($object, 'date_modification')) {
$object->date_modification = null;
}
// ...
// Clear extrafields that are unique
if (is_array($object->array_options) && count($object->array_options) > 0)
{
if (is_array($object->array_options) && count($object->array_options) > 0) {
$extrafields->fetch_name_optionals_label($this->table_element);
foreach ($object->array_options as $key => $option)
{
foreach ($object->array_options as $key => $option) {
$shortkey = preg_replace('/options_/', '', $key);
if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey]))
{
if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
//var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
unset($object->array_options[$key]);
}
@ -273,22 +280,19 @@ class RecruitmentCandidature extends CommonObject
$this->errors = $object->errors;
}
if (!$error)
{
if (!$error) {
// copy internal contacts
if ($this->copy_linked_contact($object, 'internal') < 0)
{
if ($this->copy_linked_contact($object, 'internal') < 0) {
$error++;
}
}
if (!$error)
{
if (!$error) {
// copy external contacts if same company
if (property_exists($this, 'socid') && $this->socid == $object->socid)
{
if ($this->copy_linked_contact($object, 'external') < 0)
if (property_exists($this, 'socid') && $this->socid == $object->socid) {
if ($this->copy_linked_contact($object, 'external') < 0) {
$error++;
}
}
}
@ -315,9 +319,13 @@ class RecruitmentCandidature extends CommonObject
public function fetch($id, $ref = null, $email_msgid = '')
{
$morewhere = '';
if ($email_msgid) $morewhere = " AND email_msgid = '".$this->db->escape($email_msgid)."'";
if ($email_msgid) {
$morewhere = " AND email_msgid = '".$this->db->escape($email_msgid)."'";
}
$result = $this->fetchCommon($id, $ref, $morewhere);
if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
if ($result > 0 && !empty($this->table_element_line)) {
$this->fetchLines();
}
return $result;
}
@ -357,8 +365,11 @@ class RecruitmentCandidature extends CommonObject
$sql = 'SELECT ';
$sql .= $this->getFieldList();
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
else $sql .= ' WHERE 1 = 1';
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
$sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
} else {
$sql .= ' WHERE 1 = 1';
}
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
@ -391,8 +402,7 @@ class RecruitmentCandidature extends CommonObject
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < ($limit ? min($limit, $num) : $num))
{
while ($i < ($limit ? min($limit, $num) : $num)) {
$obj = $this->db->fetch_object($resql);
$record = new self($this->db);
@ -448,8 +458,7 @@ class RecruitmentCandidature extends CommonObject
*/
public function deleteLine(User $user, $idline, $notrigger = false)
{
if ($this->status < 0)
{
if ($this->status < 0) {
$this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
return -2;
}
@ -474,8 +483,7 @@ class RecruitmentCandidature extends CommonObject
$error = 0;
// Protection
if ($this->status == self::STATUS_VALIDATED)
{
if ($this->status == self::STATUS_VALIDATED) {
dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
return 0;
}
@ -493,8 +501,7 @@ class RecruitmentCandidature extends CommonObject
$this->db->begin();
// Define new ref
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
{
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
$num = $this->getNextNumRef();
} else {
$num = $this->ref;
@ -506,57 +513,58 @@ class RecruitmentCandidature extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET ref = '".$this->db->escape($num)."',";
$sql .= " status = ".self::STATUS_VALIDATED;
if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."',";
if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id;
if (!empty($this->fields['date_validation'])) {
$sql .= ", date_validation = '".$this->db->idate($now)."',";
}
if (!empty($this->fields['fk_user_valid'])) {
$sql .= ", fk_user_valid = ".$user->id;
}
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
dol_print_error($this->db);
$this->error = $this->db->lasterror();
$error++;
}
if (!$error && !$notrigger)
{
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('RECRUITMENTCANDIDATURE_VALIDATE', $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
// End call triggers
}
}
if (!$error)
{
if (!$error) {
$this->oldref = $this->ref;
// Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref))
{
if (preg_match('/^[\(]?PROV/i', $this->ref)) {
// Now we rename also files into index
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'recruitmentcandidature/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'recruitmentcandidature/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->error = $this->db->lasterror(); }
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->recruitment->dir_output.'/recruitmentcandidature/'.$oldref;
$dirdest = $conf->recruitment->dir_output.'/recruitmentcandidature/'.$newref;
if (!$error && file_exists($dirsource))
{
if (!$error && file_exists($dirsource)) {
dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest))
{
if (@rename($dirsource, $dirdest)) {
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles = dol_dir_list($conf->recruitment->dir_output.'/recruitmentcandidature/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
foreach ($listoffiles as $fileentry)
{
foreach ($listoffiles as $fileentry) {
$dirsource = $fileentry['name'];
$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
$dirsource = $fileentry['path'].'/'.$dirsource;
@ -569,14 +577,12 @@ class RecruitmentCandidature extends CommonObject
}
// Set new ref and current status
if (!$error)
{
if (!$error) {
$this->ref = $num;
$this->status = self::STATUS_VALIDATED;
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -596,8 +602,7 @@ class RecruitmentCandidature extends CommonObject
public function setDraft($user, $notrigger = 0)
{
// Protection
if ($this->status <= self::STATUS_DRAFT)
{
if ($this->status <= self::STATUS_DRAFT) {
return 0;
}
@ -621,8 +626,7 @@ class RecruitmentCandidature extends CommonObject
public function cancel($user, $notrigger = 0)
{
// Protection
if ($this->status != self::STATUS_VALIDATED)
{
if ($this->status != self::STATUS_VALIDATED) {
return 0;
}
@ -646,8 +650,7 @@ class RecruitmentCandidature extends CommonObject
public function reopen($user, $notrigger = 0)
{
// Protection
if ($this->status != self::STATUS_REFUSED && $this->status != self::STATUS_CANCELED && $this->status != self::STATUS_CONTRACT_REFUSED)
{
if ($this->status != self::STATUS_REFUSED && $this->status != self::STATUS_CANCELED && $this->status != self::STATUS_CONTRACT_REFUSED) {
return 0;
}
@ -675,7 +678,9 @@ class RecruitmentCandidature extends CommonObject
{
global $conf, $langs, $hookmanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = '';
@ -690,25 +695,28 @@ class RecruitmentCandidature extends CommonObject
$url = dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?id='.$this->id;
if ($option != 'nolink')
{
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
}
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowRecruitmentCandidature");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
@ -717,7 +725,9 @@ class RecruitmentCandidature extends CommonObject
$result .= $linkstart;
if (empty($this->showphoto_on_popup)) {
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
} else {
if ($withpicto) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -743,7 +753,9 @@ class RecruitmentCandidature extends CommonObject
}
}
if ($withpicto != 2) $result .= $this->ref;
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@ -752,8 +764,11 @@ class RecruitmentCandidature extends CommonObject
$hookmanager->initHooks(array('recruitmentcandidaturedao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint;
else $result .= $hookmanager->resPrint;
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result;
}
@ -780,8 +795,7 @@ class RecruitmentCandidature extends CommonObject
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("recruitment@recruitment");
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
@ -802,7 +816,9 @@ class RecruitmentCandidature extends CommonObject
$statusType = 'status'.$status;
//if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
if ($status == self::STATUS_CANCELED) $statusType = 'status6';
if ($status == self::STATUS_CANCELED) {
$statusType = 'status6';
}
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
@ -820,28 +836,23 @@ class RecruitmentCandidature extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
if ($result) {
if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid)
{
if ($obj->fk_user_valid) {
$vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
if ($obj->fk_user_cloture)
{
if ($obj->fk_user_cloture) {
$cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;
@ -881,8 +892,7 @@ class RecruitmentCandidature extends CommonObject
$objectline = new RecruitmentCandidatureLine($this->db);
$result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_recruitmentcandidature = '.$this->id));
if (is_numeric($result))
{
if (is_numeric($result)) {
$this->error = $this->error;
$this->errors = $this->errors;
return $result;
@ -906,8 +916,7 @@ class RecruitmentCandidature extends CommonObject
$conf->global->RECRUITMENT_RECRUITMENTCANDIDATURE_ADDON = 'mod_recruitmentcandidature_standard';
}
if (!empty($conf->global->RECRUITMENT_RECRUITMENTCANDIDATURE_ADDON))
{
if (!empty($conf->global->RECRUITMENT_RECRUITMENTCANDIDATURE_ADDON)) {
$mybool = false;
$file = $conf->global->RECRUITMENT_RECRUITMENTCANDIDATURE_ADDON.".php";
@ -915,16 +924,14 @@ class RecruitmentCandidature extends CommonObject
// Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/recruitment/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
}
if ($mybool === false)
{
if ($mybool === false) {
dol_print_error('', "Failed to include file ".$file);
return '';
}
@ -933,8 +940,7 @@ class RecruitmentCandidature extends CommonObject
$obj = new $classname();
$numref = $obj->getNextValue($this);
if ($numref != '' && $numref != '-1')
{
if ($numref != '' && $numref != '-1') {
return $numref;
} else {
$this->error = $obj->error;
@ -972,8 +978,7 @@ class RecruitmentCandidature extends CommonObject
$langs->load("recruitment@recruitment");
if (!dol_strlen($modele)) {
if (!empty($conf->global->RECRUITMENTCANDIDATURE_ADDON_PDF))
{
if (!empty($conf->global->RECRUITMENTCANDIDATURE_ADDON_PDF)) {
$modele = $conf->global->RECRUITMENTCANDIDATURE_ADDON_PDF;
} else {
$modele = ''; // No default value. For job application, we allow to disable all PDF generation

View File

@ -179,8 +179,12 @@ class RecruitmentJobPosition extends CommonObject
$this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0;
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['rowid']['visible'] = 0;
}
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
// Example to show how to set values of fields definition dynamically
/*if ($user->rights->recruitment->recruitmentjobposition->read) {
@ -189,23 +193,17 @@ class RecruitmentJobPosition extends CommonObject
}*/
// Unset fields that are disabled
foreach ($this->fields as $key => $val)
{
if (isset($val['enabled']) && empty($val['enabled']))
{
foreach ($this->fields as $key => $val) {
if (isset($val['enabled']) && empty($val['enabled'])) {
unset($this->fields[$key]);
}
}
// Translate some data of arrayofkeyval
if (is_object($langs))
{
foreach ($this->fields as $key => $val)
{
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval']))
{
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
if (is_object($langs)) {
foreach ($this->fields as $key => $val) {
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
foreach ($val['arrayofkeyval'] as $key2 => $val2) {
$this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
}
}
@ -245,7 +243,9 @@ class RecruitmentJobPosition extends CommonObject
// Load source object
$result = $object->fetchCommon($fromid);
if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
if ($result > 0 && !empty($object->table_element_line)) {
$object->fetchLines();
}
// get lines so they will be clone
//foreach($this->lines as $line)
@ -257,21 +257,28 @@ class RecruitmentJobPosition extends CommonObject
unset($object->import_key);
// Clear fields
if (property_exists($object, 'ref')) $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
if (property_exists($object, 'label')) $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
if (property_exists($object, 'status')) { $object->status = self::STATUS_DRAFT; }
if (property_exists($object, 'date_creation')) { $object->date_creation = dol_now(); }
if (property_exists($object, 'date_modification')) { $object->date_modification = null; }
if (property_exists($object, 'ref')) {
$object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
}
if (property_exists($object, 'label')) {
$object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
}
if (property_exists($object, 'status')) {
$object->status = self::STATUS_DRAFT;
}
if (property_exists($object, 'date_creation')) {
$object->date_creation = dol_now();
}
if (property_exists($object, 'date_modification')) {
$object->date_modification = null;
}
// ...
// Clear extrafields that are unique
if (is_array($object->array_options) && count($object->array_options) > 0)
{
if (is_array($object->array_options) && count($object->array_options) > 0) {
$extrafields->fetch_name_optionals_label($this->table_element);
foreach ($object->array_options as $key => $option)
{
foreach ($object->array_options as $key => $option) {
$shortkey = preg_replace('/options_/', '', $key);
if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey]))
{
if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) {
//var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
unset($object->array_options[$key]);
}
@ -287,22 +294,19 @@ class RecruitmentJobPosition extends CommonObject
$this->errors = $object->errors;
}
if (!$error)
{
if (!$error) {
// copy internal contacts
if ($this->copy_linked_contact($object, 'internal') < 0)
{
if ($this->copy_linked_contact($object, 'internal') < 0) {
$error++;
}
}
if (!$error)
{
if (!$error) {
// copy external contacts if same company
if (property_exists($this, 'socid') && $this->socid == $object->socid)
{
if ($this->copy_linked_contact($object, 'external') < 0)
if (property_exists($this, 'socid') && $this->socid == $object->socid) {
if ($this->copy_linked_contact($object, 'external') < 0) {
$error++;
}
}
}
@ -328,7 +332,9 @@ class RecruitmentJobPosition extends CommonObject
public function fetch($id, $ref = null)
{
$result = $this->fetchCommon($id, $ref);
if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
if ($result > 0 && !empty($this->table_element_line)) {
$this->fetchLines();
}
return $result;
}
@ -368,8 +374,11 @@ class RecruitmentJobPosition extends CommonObject
$sql = 'SELECT ';
$sql .= $this->getFieldList();
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
else $sql .= ' WHERE 1 = 1';
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
$sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
} else {
$sql .= ' WHERE 1 = 1';
}
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
@ -402,8 +411,7 @@ class RecruitmentJobPosition extends CommonObject
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < ($limit ? min($limit, $num) : $num))
{
while ($i < ($limit ? min($limit, $num) : $num)) {
$obj = $this->db->fetch_object($resql);
$record = new self($this->db);
@ -459,8 +467,7 @@ class RecruitmentJobPosition extends CommonObject
*/
public function deleteLine(User $user, $idline, $notrigger = false)
{
if ($this->status < 0)
{
if ($this->status < 0) {
$this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
return -2;
}
@ -485,8 +492,7 @@ class RecruitmentJobPosition extends CommonObject
$error = 0;
// Protection
if ($this->status == self::STATUS_VALIDATED)
{
if ($this->status == self::STATUS_VALIDATED) {
dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
return 0;
}
@ -504,8 +510,7 @@ class RecruitmentJobPosition extends CommonObject
$this->db->begin();
// Define new ref
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
{
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
$num = $this->getNextNumRef();
} else {
$num = $this->ref;
@ -517,57 +522,58 @@ class RecruitmentJobPosition extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET ref = '".$this->db->escape($num)."',";
$sql .= " status = ".self::STATUS_VALIDATED;
if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."',";
if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id;
if (!empty($this->fields['date_validation'])) {
$sql .= ", date_validation = '".$this->db->idate($now)."',";
}
if (!empty($this->fields['fk_user_valid'])) {
$sql .= ", fk_user_valid = ".$user->id;
}
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
dol_print_error($this->db);
$this->error = $this->db->lasterror();
$error++;
}
if (!$error && !$notrigger)
{
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('RECRUITMENTJOBPOSITION_VALIDATE', $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
// End call triggers
}
}
if (!$error)
{
if (!$error) {
$this->oldref = $this->ref;
// Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref))
{
if (preg_match('/^[\(]?PROV/i', $this->ref)) {
// Now we rename also files into index
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'recruitmentjobposition/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'recruitmentjobposition/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->error = $this->db->lasterror(); }
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->recruitment->dir_output.'/recruitmentjobposition/'.$oldref;
$dirdest = $conf->recruitment->dir_output.'/recruitmentjobposition/'.$newref;
if (!$error && file_exists($dirsource))
{
if (!$error && file_exists($dirsource)) {
dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest))
{
if (@rename($dirsource, $dirdest)) {
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles = dol_dir_list($conf->recruitment->dir_output.'/recruitmentjobposition/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
foreach ($listoffiles as $fileentry)
{
foreach ($listoffiles as $fileentry) {
$dirsource = $fileentry['name'];
$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
$dirsource = $fileentry['path'].'/'.$dirsource;
@ -580,14 +586,12 @@ class RecruitmentJobPosition extends CommonObject
}
// Set new ref and current status
if (!$error)
{
if (!$error) {
$this->ref = $num;
$this->status = self::STATUS_VALIDATED;
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -607,8 +611,7 @@ class RecruitmentJobPosition extends CommonObject
public function setDraft($user, $notrigger = 0)
{
// Protection
if ($this->status <= self::STATUS_DRAFT)
{
if ($this->status <= self::STATUS_DRAFT) {
return 0;
}
@ -632,8 +635,7 @@ class RecruitmentJobPosition extends CommonObject
public function cancel($user, $notrigger = 0)
{
// Protection
if ($this->status != self::STATUS_VALIDATED)
{
if ($this->status != self::STATUS_VALIDATED) {
return 0;
}
@ -673,30 +675,25 @@ class RecruitmentJobPosition extends CommonObject
$sql .= " WHERE rowid = ".$this->id;
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$modelpdf = $this->model_pdf;
$triggerName = 'RECRUITMENTJOB_CLOSE_REFUSED';
if ($status == self::STATUS_RECRUITED)
{
if ($status == self::STATUS_RECRUITED) {
$triggerName = 'RECRUITMENTJOB_CLOSE_RECRUITED';
$modelpdf = $this->model_pdf;
if ($result < 0)
{
if ($result < 0) {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -2;
}
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
// Define output language
$outputlangs = $langs;
if (!empty($conf->global->MAIN_MULTILANGS))
{
if (!empty($conf->global->MAIN_MULTILANGS)) {
$outputlangs = new Translate("", $conf);
$newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang);
$outputlangs->setDefaultLang($newlang);
@ -705,24 +702,23 @@ class RecruitmentJobPosition extends CommonObject
$this->generateDocument($modelpdf, $outputlangs);
}
if (!$error)
{
if (!$error) {
$this->oldcopy = clone $this;
$this->status = $status;
$this->date_cloture = $now;
$this->note_private = $newprivatenote;
}
if (!$notrigger && empty($error))
{
if (!$notrigger && empty($error)) {
// Call trigger
$result = $this->call_trigger($triggerName, $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -750,8 +746,7 @@ class RecruitmentJobPosition extends CommonObject
public function reopen($user, $notrigger = 0)
{
// Protection
if ($this->status != self::STATUS_CANCELED)
{
if ($this->status != self::STATUS_CANCELED) {
return 0;
}
@ -779,7 +774,9 @@ class RecruitmentJobPosition extends CommonObject
{
global $conf, $langs, $hookmanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = '';
@ -793,25 +790,28 @@ class RecruitmentJobPosition extends CommonObject
$url = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.$this->id;
if ($option != 'nolink')
{
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
}
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowRecruitmentJobPosition");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
@ -820,7 +820,9 @@ class RecruitmentJobPosition extends CommonObject
$result .= $linkstart;
if (empty($this->showphoto_on_popup)) {
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
} else {
if ($withpicto) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -846,7 +848,9 @@ class RecruitmentJobPosition extends CommonObject
}
}
if ($withpicto != 2) $result .= $this->ref;
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@ -855,8 +859,11 @@ class RecruitmentJobPosition extends CommonObject
$hookmanager->initHooks(array('recruitmentjobpositiondao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint;
else $result .= $hookmanager->resPrint;
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result;
}
@ -883,8 +890,7 @@ class RecruitmentJobPosition extends CommonObject
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("recruitment");
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
@ -898,9 +904,15 @@ class RecruitmentJobPosition extends CommonObject
}
$statusType = 'status'.$status;
if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
if ($status == self::STATUS_RECRUITED) $statusType = 'status6';
if ($status == self::STATUS_CANCELED) $statusType = 'status9';
if ($status == self::STATUS_VALIDATED) {
$statusType = 'status4';
}
if ($status == self::STATUS_RECRUITED) {
$statusType = 'status6';
}
if ($status == self::STATUS_CANCELED) {
$statusType = 'status9';
}
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
@ -918,28 +930,23 @@ class RecruitmentJobPosition extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
if ($result) {
if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid)
{
if ($obj->fk_user_valid) {
$vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
if ($obj->fk_user_cloture)
{
if ($obj->fk_user_cloture) {
$cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;
@ -993,8 +1000,7 @@ class RecruitmentJobPosition extends CommonObject
$conf->global->RECRUITMENT_RECRUITMENTJOBPOSITION_ADDON = 'mod_recruitmentjobposition_standard';
}
if (!empty($conf->global->RECRUITMENT_RECRUITMENTJOBPOSITION_ADDON))
{
if (!empty($conf->global->RECRUITMENT_RECRUITMENTJOBPOSITION_ADDON)) {
$mybool = false;
$file = $conf->global->RECRUITMENT_RECRUITMENTJOBPOSITION_ADDON.".php";
@ -1002,16 +1008,14 @@ class RecruitmentJobPosition extends CommonObject
// Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/recruitment/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
}
if ($mybool === false)
{
if ($mybool === false) {
dol_print_error('', "Failed to include file ".$file);
return '';
}
@ -1020,8 +1024,7 @@ class RecruitmentJobPosition extends CommonObject
$obj = new $classname();
$numref = $obj->getNextValue($this);
if ($numref != '' && $numref != '-1')
{
if ($numref != '' && $numref != '-1') {
return $numref;
} else {
$this->error = $obj->error;

View File

@ -98,7 +98,9 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
// Recupere emetteur
$this->emetteur = $mysoc;
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
if (!$this->emetteur->country_code) {
$this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
}
}
@ -129,8 +131,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
$texttitle = $langs->trans("ListOfDirectories");
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->RECRUITMENT_RECRUITMENTJOBPOSITION_ADDON_PDF_ODT_PATH)));
$listoffiles = array();
foreach ($listofdir as $key=>$tmpdir)
{
foreach ($listofdir as $key => $tmpdir) {
$tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) {
@ -140,7 +141,9 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
$texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
} else {
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
if (count($tmpfiles)) {
$listoffiles = array_merge($listoffiles, $tmpfiles);
}
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
@ -159,8 +162,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
// Scan directories
$nbofiles = count($listoffiles);
if (!empty($conf->global->RECRUITMENT_RECRUITMENTJOBPOSITION_ADDON_PDF_ODT_PATH))
{
if (!empty($conf->global->RECRUITMENT_RECRUITMENTJOBPOSITION_ADDON_PDF_ODT_PATH)) {
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
$texte .= count($listoffiles);
@ -168,11 +170,9 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
$texte .= '</b>';
}
if ($nbofiles)
{
if ($nbofiles) {
$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
foreach ($listoffiles as $file)
{
foreach ($listoffiles as $file) {
$texte .= $file['name'].'<br>';
}
$texte .= '</div>';
@ -208,37 +208,34 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
// phpcs:enable
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath))
{
if (empty($srctemplatepath)) {
dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
return -1;
}
// Add odtgeneration hook
if (!is_object($hookmanager))
{
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) $outputlangs = $langs;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
$sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8';
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
if ($conf->commande->dir_output)
{
if ($conf->commande->dir_output) {
// If $object is id instead of object
if (!is_object($object))
{
if (!is_object($object)) {
$id = $object;
$object = new Commande($this->db);
$result = $object->fetch($id);
if ($result < 0)
{
if ($result < 0) {
dol_print_error($this->db, $object->error);
return -1;
}
@ -246,20 +243,19 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
$dir = $conf->commande->multidir_output[isset($object->entity) ? $object->entity : 1];
$objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
if (!preg_match('/specimen/i', $objectref)) {
$dir .= "/".$objectref;
}
$file = $dir."/".$objectref.".odt";
if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
if (file_exists($dir))
{
if (file_exists($dir)) {
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile = basename($srctemplatepath);
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
@ -269,10 +265,11 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_TIMING))
{
if (!empty($conf->global->MAIN_DOC_USE_TIMING)) {
$format = $conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format = '%Y%m%d%H%M%S';
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
@ -289,16 +286,14 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
// If CUSTOMER contact defined on order, we use it
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
if (count($arrayidcontact) > 0)
{
if (count($arrayidcontact) > 0) {
$usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
$contactobject = null;
if (!empty($usecontact))
{
if (!empty($usecontact)) {
if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
$socobject = $object->contact;
} else {
@ -326,8 +321,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
// Line of free text
$newfreetext = '';
$paramfreetext = 'ORDER_FREE_TEXT';
if (!empty($conf->global->$paramfreetext))
{
if (!empty($conf->global->$paramfreetext)) {
$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
}
@ -343,8 +337,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
'DELIMITER_RIGHT' => '}'
)
);
} catch (Exception $e)
{
} catch (Exception $e) {
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
@ -359,8 +352,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
// Make substitutions into odt of freetext
try {
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
} catch (OdfException $e)
{
} catch (OdfException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
}
@ -374,7 +366,9 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
$array_other = $this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in object as contact_xxx tags
$array_thirdparty_contact = array();
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
if ($usecontact && is_object($contactobject)) {
$array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
}
$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
complete_substitutions_array($tmparray, $outputlangs, $object);
@ -383,19 +377,20 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key=>$value)
{
foreach ($tmparray as $key => $value) {
try {
if (preg_match('/logo$/', $key)) {
// Image
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
if (file_exists($value)) {
$odfHandler->setImage($key, $value);
} else {
$odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
} else {
// Text
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
} catch (OdfException $e)
{
} catch (OdfException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
}
}
@ -404,32 +399,26 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
$foundtagforlines = 1;
try {
$listlines = $odfHandler->setSegment('lines');
} catch (OdfException $e)
{
} catch (OdfException $e) {
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
}
if ($foundtagforlines)
{
if ($foundtagforlines) {
$linenumber = 0;
foreach ($object->lines as $line)
{
foreach ($object->lines as $line) {
$linenumber++;
$tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber);
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key => $val)
{
foreach ($tmparray as $key => $val) {
try {
$listlines->setVars($key, $val, true, 'UTF-8');
} catch (OdfException $e)
{
} catch (OdfException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
} catch (SegmentException $e)
{
} catch (SegmentException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
}
}
@ -437,8 +426,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
}
$odfHandler->mergeSegment($listlines);
}
} catch (OdfException $e)
{
} catch (OdfException $e) {
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
@ -446,12 +434,10 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
// Replace labels translated
$tmparray = $outputlangs->get_translations_for_substitutions();
foreach ($tmparray as $key=>$value)
{
foreach ($tmparray as $key => $value) {
try {
$odfHandler->setVars($key, $value, true, 'UTF-8');
} catch (OdfException $e)
{
} catch (OdfException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
}
}
@ -483,8 +469,9 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (!empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($file, octdec($conf->global->MAIN_UMASK));
}
$odfHandler = null; // Destroy object

View File

@ -174,7 +174,9 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
// Get source company
$this->emetteur = $mysoc;
if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
if (empty($this->emetteur->country_code)) {
$this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
}
// Define position of columns
$this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff
@ -212,9 +214,13 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
if (!is_object($outputlangs)) $outputlangs = $langs;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
if (!empty($conf->global->MAIN_USE_FPDF)) {
$outputlangs->charset_output = 'ISO-8859-1';
}
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
@ -237,67 +243,65 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$realpatharray = array();
$this->atleastonephoto = false;
/*
if (!empty($conf->global->MAIN_GENERATE_MYOBJECT_WITH_PICTURE))
{
$objphoto = new Product($this->db);
if (!empty($conf->global->MAIN_GENERATE_MYOBJECT_WITH_PICTURE))
{
$objphoto = new Product($this->db);
for ($i = 0; $i < $nblines; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
for ($i = 0; $i < $nblines; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto->fetch($object->lines[$i]->fk_product);
//var_dump($objphoto->ref);exit;
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
$pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
} else {
$pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
$pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
}
$objphoto->fetch($object->lines[$i]->fk_product);
//var_dump($objphoto->ref);exit;
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
$pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
} else {
$pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
$pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
}
$arephoto = false;
foreach ($pdir as $midir)
{
if (!$arephoto)
{
$dir = $conf->product->dir_output.'/'.$midir;
$arephoto = false;
foreach ($pdir as $midir)
{
if (!$arephoto)
{
$dir = $conf->product->dir_output.'/'.$midir;
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
{
if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
{
if ($obj['photo_vignette'])
{
$filename = $obj['photo_vignette'];
} else {
$filename = $obj['photo'];
}
} else {
$filename = $obj['photo'];
}
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
{
if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
{
if ($obj['photo_vignette'])
{
$filename = $obj['photo_vignette'];
} else {
$filename = $obj['photo'];
}
} else {
$filename = $obj['photo'];
}
$realpath = $dir.$filename;
$arephoto = true;
$this->atleastonephoto = true;
}
}
}
$realpath = $dir.$filename;
$arephoto = true;
$this->atleastonephoto = true;
}
}
}
if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
}
}
if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
}
}
*/
//if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
if ($conf->recruitment->dir_output.'/recruitmentjobposition')
{
if ($conf->recruitment->dir_output.'/recruitmentjobposition') {
$object->fetch_thirdparty();
// Definition of $dir and $file
if ($object->specimen)
{
if ($object->specimen) {
$dir = $conf->recruitment->dir_output.'/recruitmentjobposition';
$file = $dir."/SPECIMEN.pdf";
} else {
@ -305,20 +309,16 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$dir = $conf->recruitment->dir_output.'/recruitmentjobposition/'.$objectref;
$file = $dir."/".$objectref.".pdf";
}
if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
if (file_exists($dir))
{
if (file_exists($dir)) {
// Add pdfgeneration hook
if (!is_object($hookmanager))
{
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
@ -339,16 +339,14 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
if (class_exists('TCPDF'))
{
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
@ -362,7 +360,9 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$object->label." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
$pdf->SetCompression(false);
}
// Set certificate
$cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
@ -385,7 +385,9 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
// New page
$pdf->AddPage();
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
$pagenb++;
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
@ -397,7 +399,9 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
$tab_height = 130 - $top_shift;
$tab_height_newpage = 150;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
$tab_height_newpage -= $top_shift;
}
$nexY = $tab_top - 1;
@ -405,14 +409,12 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
// Extrafields in note
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
if (!empty($extranote))
{
if (!empty($extranote)) {
$notetoshow = dol_concatdesc($notetoshow, $extranote);
}
$pagenb = $pdf->getPage();
if ($notetoshow)
{
if ($notetoshow) {
$tab_top -= 2;
$tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
@ -431,16 +433,19 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$pageposafternote = $pdf->getPage();
$posyafter = $pdf->GetY();
if ($pageposafternote > $pageposbeforenote)
{
if ($pageposafternote > $pageposbeforenote) {
$pdf->rollbackTransaction(true);
// prepare pages to receive notes
while ($pagenb < $pageposafternote) {
$pdf->AddPage();
$pagenb++;
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
$this->_pagehead($pdf, $object, 0, $outputlangs);
}
// $this->_pagefoot($pdf,$object,$outputlangs,1);
$pdf->setTopMargin($tab_top_newpage);
// The only function to edit the bottom margin of current page to set it.
@ -456,8 +461,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$posyafter = $pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text
{
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
$pdf->AddPage('', '', true);
$pagenb++;
$pageposafternote++;
@ -494,8 +498,12 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
// apply note frame to last page
$pdf->setPage($pageposafternote);
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
$this->_pagehead($pdf, $object, 0, $outputlangs);
}
$height_note = $posyafter - $tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
} else // No pagebreak
@ -505,15 +513,18 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$height_note = $posyafter - $tab_top;
$pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
{
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
// not enough space, need to add page
$pdf->AddPage('', '', true);
$pagenb++;
$pageposafternote++;
$pdf->setPage($pageposafternote);
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
$this->_pagehead($pdf, $object, 0, $outputlangs);
}
$posyafter = $tab_top_newpage;
}
@ -538,15 +549,16 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
// Loop on each lines
$pageposbeforeprintlines = $pdf->getPage();
$pagenb = $pageposbeforeprintlines;
for ($i = 0; $i < $nblines; $i++)
{
for ($i = 0; $i < $nblines; $i++) {
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
$imglinesize = array();
if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
if (!empty($realpatharray[$i])) {
$imglinesize = pdf_getSizeForImage($realpatharray[$i]);
}
$pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
@ -555,25 +567,26 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$showpricebeforepagebreak = 1;
$posYAfterImage = 0;
if ($this->getColumnStatus('photo'))
{
if ($this->getColumnStatus('photo')) {
// We start with Photo of product line
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page
{
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
$pdf->AddPage('', '', true);
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
$pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
$showpricebeforepagebreak = 1;
else $showpricebeforepagebreak = 0;
} else {
$showpricebeforepagebreak = 0;
}
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
{
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height'];
@ -581,15 +594,13 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
}
// Description of product line
if ($this->getColumnStatus('desc'))
{
if ($this->getColumnStatus('desc')) {
$pdf->startTransaction();
$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
$pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
if ($pageposafter > $pageposbefore) { // There is a pagebreak
$pdf->rollbackTransaction(true);
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
@ -598,20 +609,22 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
{
if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
$pdf->AddPage('', '', true);
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
$pdf->setPage($pageposafter + 1);
}
} else {
// We found a page break
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
$showpricebeforepagebreak = 1;
else $showpricebeforepagebreak = 0;
} else {
$showpricebeforepagebreak = 0;
}
}
} else // No pagebreak
{
@ -659,7 +672,9 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$pagenb++;
$pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
$this->_pagehead($pdf, $object, 0, $outputlangs);
}
}
if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
@ -671,15 +686,18 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$this->_pagefoot($pdf, $object, $outputlangs, 1);
// New page
$pdf->AddPage();
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
$pagenb++;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
$this->_pagehead($pdf, $object, 0, $outputlangs);
}
}
}
// Show square
if ($pagenb == $pageposbeforeprintlines)
{
if ($pagenb == $pageposbeforeprintlines) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} else {
@ -695,15 +713,17 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
// Display payment area
/*
if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
{
$posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
}
*/
if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
{
$posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
}
*/
// Pagefoot
$this->_pagefoot($pdf, $object, $outputlangs);
if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
if (method_exists($pdf, 'AliasNbPages')) {
$pdf->AliasNbPages();
}
$pdf->Close();
@ -714,14 +734,14 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
if ($reshook < 0) {
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
if (!empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($file, octdec($conf->global->MAIN_UMASK));
}
$this->result = array('fullpath'=>$file);
@ -771,7 +791,9 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
// Force to disable hidetop and hidebottom
$hidebottom = 0;
if ($hidetop) $hidetop = -1;
if ($hidetop) {
$hidetop = -1;
}
$currency = !empty($currency) ? $currency : $conf->currency;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@ -780,8 +802,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
if (empty($hidetop))
{
if (empty($hidetop)) {
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
@ -825,8 +846,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
{
if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
}
@ -841,20 +861,18 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$pdf->SetXY($this->marge_gauche, $posy);
// Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
{
if ($this->emetteur->logo)
{
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) {
if ($this->emetteur->logo) {
$logodir = $conf->mycompany->dir_output;
if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
}
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
} else {
$logo = $logodir.'/logos/'.$this->emetteur->logo;
}
if (is_readable($logo))
{
if (is_readable($logo)) {
$height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else {
@ -885,8 +903,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
if ($object->statut == $object::STATUS_DRAFT)
{
if ($object->statut == $object::STATUS_DRAFT) {
$pdf->SetTextColor(128, 0, 0);
$textref .= ' - '.$outputlangs->transnoentities("NotValidated");
}
@ -895,19 +912,16 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$posy += 1;
$pdf->SetFont('', '', $default_font_size - 2);
if ($object->ref_client)
{
if ($object->ref_client) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
{
if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
$object->fetch_projet();
if (!empty($object->project->ref))
{
if (!empty($object->project->ref)) {
$posy += 3;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@ -915,11 +929,9 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
}
}
if (!empty($conf->global->PDF_SHOW_PROJECT))
{
if (!empty($conf->global->PDF_SHOW_PROJECT)) {
$object->fetch_projet();
if (!empty($object->project->ref))
{
if (!empty($object->project->ref)) {
$posy += 3;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@ -937,8 +949,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
}
$pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date_creation, "day", false, $outputlangs), '', 'R');
if ($object->thirdparty->code_client)
{
if ($object->thirdparty->code_client) {
$posy += 3;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@ -951,13 +962,11 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
// Show list of linked objects
$current_y = $pdf->getY();
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
if ($current_y < $pdf->getY())
{
if ($current_y < $pdf->getY()) {
$top_shift = $pdf->getY() - $current_y;
}
if ($showaddress)
{
if ($showaddress) {
// Sender properties
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
@ -965,7 +974,9 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
$posy += $top_shift;
$posx = $this->marge_gauche;
if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
$posx = $this->page_largeur - $this->marge_droite - 80;
}
$hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
@ -995,8 +1006,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
// If BILLING contact defined on invoice, we use it
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'BILLING');
if (count($arrayidcontact) > 0)
{
if (count($arrayidcontact) > 0) {
$usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]);
}
@ -1091,162 +1101,162 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
);
/*
* For exemple
$this->cols['theColKey'] = array(
'rank' => $rank, // int : use for ordering columns
'width' => 20, // the column width in mm
'title' => array(
'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
'label' => ' ', // the final label : used fore final generated text
'align' => 'L', // text alignement : R,C,L
'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
'content' => array(
'align' => 'L', // text alignement : R,C,L
'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
);
*/
* For exemple
$this->cols['theColKey'] = array(
'rank' => $rank, // int : use for ordering columns
'width' => 20, // the column width in mm
'title' => array(
'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
'label' => ' ', // the final label : used fore final generated text
'align' => 'L', // text alignement : R,C,L
'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
'content' => array(
'align' => 'L', // text alignement : R,C,L
'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
);
*/
$rank = 0; // do not use negative rank
/*
$this->cols['desc'] = array(
'rank' => $rank,
'width' => false, // only for desc
'status' => true,
'title' => array(
'textkey' => 'Designation', // use lang key is usefull in somme case with module
'align' => 'L',
// 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
// 'label' => ' ', // the final label
'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
'content' => array(
'align' => 'L',
'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
);
$this->cols['desc'] = array(
'rank' => $rank,
'width' => false, // only for desc
'status' => true,
'title' => array(
'textkey' => 'Designation', // use lang key is usefull in somme case with module
'align' => 'L',
// 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
// 'label' => ' ', // the final label
'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
'content' => array(
'align' => 'L',
'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
);
// PHOTO
$rank = $rank + 10;
$this->cols['photo'] = array(
'rank' => $rank,
'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
'status' => false,
'title' => array(
'textkey' => 'Photo',
'label' => ' '
),
'content' => array(
'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
'border-left' => false, // remove left line separator
);
// PHOTO
$rank = $rank + 10;
$this->cols['photo'] = array(
'rank' => $rank,
'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
'status' => false,
'title' => array(
'textkey' => 'Photo',
'label' => ' '
),
'content' => array(
'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
'border-left' => false, // remove left line separator
);
if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
{
$this->cols['photo']['status'] = true;
}
if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
{
$this->cols['photo']['status'] = true;
}
$rank = $rank + 10;
$this->cols['vat'] = array(
'rank' => $rank,
'status' => false,
'width' => 16, // in mm
'title' => array(
'textkey' => 'VAT'
),
'border-left' => true, // add left line separator
);
$rank = $rank + 10;
$this->cols['vat'] = array(
'rank' => $rank,
'status' => false,
'width' => 16, // in mm
'title' => array(
'textkey' => 'VAT'
),
'border-left' => true, // add left line separator
);
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
{
$this->cols['vat']['status'] = true;
}
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
{
$this->cols['vat']['status'] = true;
}
$rank = $rank + 10;
$this->cols['subprice'] = array(
'rank' => $rank,
'width' => 19, // in mm
'status' => true,
'title' => array(
'textkey' => 'PriceUHT'
),
'border-left' => true, // add left line separator
);
$rank = $rank + 10;
$this->cols['subprice'] = array(
'rank' => $rank,
'width' => 19, // in mm
'status' => true,
'title' => array(
'textkey' => 'PriceUHT'
),
'border-left' => true, // add left line separator
);
$rank = $rank + 10;
$this->cols['qty'] = array(
'rank' => $rank,
'width' => 16, // in mm
'status' => true,
'title' => array(
'textkey' => 'Qty'
),
'border-left' => true, // add left line separator
);
$rank = $rank + 10;
$this->cols['qty'] = array(
'rank' => $rank,
'width' => 16, // in mm
'status' => true,
'title' => array(
'textkey' => 'Qty'
),
'border-left' => true, // add left line separator
);
$rank = $rank + 10;
$this->cols['progress'] = array(
'rank' => $rank,
'width' => 19, // in mm
'status' => false,
'title' => array(
'textkey' => 'Progress'
),
'border-left' => true, // add left line separator
);
$rank = $rank + 10;
$this->cols['progress'] = array(
'rank' => $rank,
'width' => 19, // in mm
'status' => false,
'title' => array(
'textkey' => 'Progress'
),
'border-left' => true, // add left line separator
);
if ($this->situationinvoice)
{
$this->cols['progress']['status'] = true;
}
if ($this->situationinvoice)
{
$this->cols['progress']['status'] = true;
}
$rank = $rank + 10;
$this->cols['unit'] = array(
'rank' => $rank,
'width' => 11, // in mm
'status' => false,
'title' => array(
'textkey' => 'Unit'
),
'border-left' => true, // add left line separator
);
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$this->cols['unit']['status'] = true;
}
$rank = $rank + 10;
$this->cols['unit'] = array(
'rank' => $rank,
'width' => 11, // in mm
'status' => false,
'title' => array(
'textkey' => 'Unit'
),
'border-left' => true, // add left line separator
);
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$this->cols['unit']['status'] = true;
}
$rank = $rank + 10;
$this->cols['discount'] = array(
'rank' => $rank,
'width' => 13, // in mm
'status' => false,
'title' => array(
'textkey' => 'ReductionShort'
),
'border-left' => true, // add left line separator
);
if ($this->atleastonediscount) {
$this->cols['discount']['status'] = true;
}
$rank = $rank + 10;
$this->cols['discount'] = array(
'rank' => $rank,
'width' => 13, // in mm
'status' => false,
'title' => array(
'textkey' => 'ReductionShort'
),
'border-left' => true, // add left line separator
);
if ($this->atleastonediscount) {
$this->cols['discount']['status'] = true;
}
$rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
$this->cols['totalexcltax'] = array(
'rank' => $rank,
'width' => 26, // in mm
'status' => true,
'title' => array(
'textkey' => 'TotalHT'
),
'border-left' => true, // add left line separator
);
$rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
$this->cols['totalexcltax'] = array(
'rank' => $rank,
'width' => 26, // in mm
'status' => true,
'title' => array(
'textkey' => 'TotalHT'
),
'border-left' => true, // add left line separator
);
// Add extrafields cols
if (!empty($object->lines)) {
$line = reset($object->lines);
$this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
}
// Add extrafields cols
if (!empty($object->lines)) {
$line = reset($object->lines);
$this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
}
*/
$parameters = array(
@ -1258,11 +1268,9 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
);
$reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
if ($reshook < 0)
{
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
} elseif (empty($reshook))
{
} elseif (empty($reshook)) {
$this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
} else {
$this->cols = $hookmanager->resArray;

View File

@ -96,13 +96,13 @@ class mod_recruitmentcandidature_standard extends ModeleNumRefRecruitmentCandida
}
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
if ($row) {
$coyymm = substr($row[0], 0, 6); $max = $row[0];
}
}
if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
$langs->load("errors");
$this->error = $langs->trans('ErrorNumRefModel', $max);
return false;
@ -133,11 +133,13 @@ class mod_recruitmentcandidature_standard extends ModeleNumRefRecruitmentCandida
}
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max = 0;
if ($obj) {
$max = intval($obj->max);
} else {
$max = 0;
}
} else {
dol_syslog("mod_recruitmentcandidature_standard::getNextValue", LOG_DEBUG);
return -1;
@ -147,8 +149,11 @@ class mod_recruitmentcandidature_standard extends ModeleNumRefRecruitmentCandida
$date = $object->date_creation;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
if ($max >= (pow(10, 4) - 1)) {
$num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
} else {
$num = sprintf("%04s", $max + 1);
}
dol_syslog("mod_recruitmentcandidature_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;

View File

@ -113,8 +113,7 @@ class mod_recruitmentjobposition_advanced extends ModeleNumRefRecruitmentJobPosi
/*$mysoc->code_client = $old_code_client;
$mysoc->typent_code = $old_code_type;*/
if (!$numExample)
{
if (!$numExample) {
$numExample = $langs->trans('NotConfigured');
}
return $numExample;
@ -135,8 +134,7 @@ class mod_recruitmentjobposition_advanced extends ModeleNumRefRecruitmentJobPosi
// We get cursor rule
$mask = $conf->global->RECRUITMENT_RECRUITMENTJOBPOSITION_ADVANCED_MASK;
if (!$mask)
{
if (!$mask) {
$this->error = 'NotConfigured';
return 0;
}

View File

@ -96,13 +96,13 @@ class mod_recruitmentjobposition_standard extends ModeleNumRefRecruitmentJobPosi
}
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
if ($row) {
$coyymm = substr($row[0], 0, 6); $max = $row[0];
}
}
if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
$langs->load("errors");
$this->error = $langs->trans('ErrorNumRefModel', $max);
return false;
@ -133,11 +133,13 @@ class mod_recruitmentjobposition_standard extends ModeleNumRefRecruitmentJobPosi
}
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max = 0;
if ($obj) {
$max = intval($obj->max);
} else {
$max = 0;
}
} else {
dol_syslog("mod_recruitmentjobposition_standard::getNextValue", LOG_DEBUG);
return -1;
@ -147,8 +149,11 @@ class mod_recruitmentjobposition_standard extends ModeleNumRefRecruitmentJobPosi
$date = $object->date_creation;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
if ($max >= (pow(10, 4) - 1)) {
$num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
} else {
$num = sprintf("%04s", $max + 1);
}
dol_syslog("mod_recruitmentjobposition_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;

View File

@ -141,10 +141,18 @@ abstract class ModeleNumRefRecruitmentCandidature
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
if ($this->version == 'development') {
return $langs->trans("VersionDevelopment");
}
if ($this->version == 'experimental') {
return $langs->trans("VersionExperimental");
}
if ($this->version == 'dolibarr') {
return DOL_VERSION;
}
if ($this->version) {
return $this->version;
}
return $langs->trans("NotAvailable");
}
}

View File

@ -141,10 +141,18 @@ abstract class ModeleNumRefRecruitmentJobPosition
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
if ($this->version == 'development') {
return $langs->trans("VersionDevelopment");
}
if ($this->version == 'experimental') {
return $langs->trans("VersionExperimental");
}
if ($this->version == 'dolibarr') {
return DOL_VERSION;
}
if ($this->version) {
return $this->version;
}
return $langs->trans("NotAvailable");
}
}

View File

@ -48,14 +48,19 @@ function recruitmentCandidaturePrepareHead($object)
$h++;
}
if (isset($object->fields['note_public']) || isset($object->fields['note_private']))
{
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
$nbNote = 0;
if (!empty($object->note_private)) $nbNote++;
if (!empty($object->note_public)) $nbNote++;
if (!empty($object->note_private)) {
$nbNote++;
}
if (!empty($object->note_public)) {
$nbNote++;
}
$head[$h][0] = dol_buildpath('/recruitment/recruitmentcandidature_note.php', 1).'?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
if ($nbNote > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
}
$head[$h][2] = 'note';
$h++;
}
@ -67,7 +72,9 @@ function recruitmentCandidaturePrepareHead($object)
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = dol_buildpath("/recruitment/recruitmentcandidature_document.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
if (($nbFiles + $nbLinks) > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
}
$head[$h][2] = 'document';
$h++;

View File

@ -48,14 +48,19 @@ function recruitmentjobpositionPrepareHead($object)
$h++;
}
if (isset($object->fields['note_public']) || isset($object->fields['note_private']))
{
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
$nbNote = 0;
if (!empty($object->note_private)) $nbNote++;
if (!empty($object->note_public)) $nbNote++;
if (!empty($object->note_private)) {
$nbNote++;
}
if (!empty($object->note_public)) {
$nbNote++;
}
$head[$h][0] = dol_buildpath('/recruitment/recruitmentjobposition_note.php', 1).'?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
if ($nbNote > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
}
$head[$h][2] = 'note';
$h++;
}
@ -67,7 +72,9 @@ function recruitmentjobpositionPrepareHead($object)
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = dol_buildpath("/recruitment/recruitmentjobposition_document.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
if (($nbFiles + $nbLinks) > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
}
$head[$h][2] = 'document';
$h++;
@ -113,7 +120,9 @@ function getPublicJobPositionUrl($mode, $ref = '', $localorexternal = 0)
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$urltouse = DOL_MAIN_URL_ROOT;
if ($localorexternal) $urltouse = $urlwithroot;
if ($localorexternal) {
$urltouse = $urlwithroot;
}
$out = $urltouse.'/public/recruitment/view.php?ref='.($mode ? '<font color="#666666">' : '').$ref.($mode ? '</font>' : '');
/*if (!empty($conf->global->RECRUITMENT_SECURITY_TOKEN))
@ -123,7 +132,9 @@ function getPublicJobPositionUrl($mode, $ref = '', $localorexternal = 0)
}*/
// For multicompany
if (!empty($out) && !empty($conf->multicompany->enabled)) $out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities
if (!empty($out) && !empty($conf->multicompany->enabled)) {
$out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities
}
return $out;
}

View File

@ -25,17 +25,33 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
@ -56,7 +72,9 @@ $backtopage = GETPOST('backtopage', 'alpha');
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0';
if (!count($actioncode)) {
$actioncode = '0';
}
} else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
}
@ -66,12 +84,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = 'a.datep,a.id';
if (!$sortorder) $sortorder = 'DESC,DESC';
if (!$sortfield) {
$sortfield = 'a.datep,a.id';
}
if (!$sortorder) {
$sortorder = 'DESC,DESC';
}
// Initialize technical objects
$object = new RecruitmentCandidature($db);
@ -83,7 +107,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
}
// Security check - Protection if external user
//if ($user->socid > 0) accessforbidden();
@ -99,20 +125,19 @@ $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; //
$parameters = array('id'=>$id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Cancel
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
{
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$actioncode = '';
$search_agenda_label = '';
}
@ -126,14 +151,15 @@ if (empty($reshook))
$form = new Form($db);
if ($object->id > 0)
{
if ($object->id > 0) {
$title = $langs->trans("Agenda");
//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
$help_url = '';
llxHeader('', $title, $help_url);
if (!empty($conf->notification->enabled)) $langs->load("mails");
if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = recruitmentCandidaturePrepareHead($object);
@ -206,10 +232,11 @@ if ($object->id > 0)
$out = '&origin='.$object->element.'@recruitment&originid='.$object->id;
$permok = $user->rights->agenda->myactions->create;
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok)
{
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
//$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
if (get_class($objthirdparty) == 'Societe') $out .= '&amp;socid='.$objthirdparty->id;
if (get_class($objthirdparty) == 'Societe') {
$out .= '&amp;socid='.$objthirdparty->id;
}
$out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;backtopage=1&amp;percentage=-1';
//$out.=$langs->trans("AddAnAction").' ';
//$out.=img_picto($langs->trans("AddAnAction"),'filenew');
@ -219,10 +246,8 @@ if ($object->id > 0)
print '<div class="tabsAction">';
if (!empty($conf->agenda->enabled))
{
if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
{
if (!empty($conf->agenda->enabled)) {
if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
@ -231,11 +256,14 @@ if ($object->id > 0)
print '</div>';
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
{
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$param = '&id='.$object->id.'&socid='.$socid;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
//print load_fiche_titre($langs->trans("ActionsOnRecruitmentJobPosition"), '', '');

View File

@ -44,17 +44,33 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
@ -92,12 +108,15 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha');
$search = array();
foreach ($object->fields as $key => $val)
{
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha')) {
$search[$key] = GETPOST('search_'.$key, 'alpha');
}
}
if (empty($action) && empty($id) && empty($ref)) $action = 'view';
if (empty($action) && empty($id) && empty($ref)) {
$action = 'view';
}
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
@ -125,18 +144,22 @@ $upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $obje
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
$error = 0;
$backurlforlist = dol_buildpath('/recruitment/recruitmentcandidature_list.php', 1);
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
$backtopage = $backurlforlist;
} else {
$backtopage = dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
}
}
}
$triggermodname = 'RECRUITMENTCANDIDATURE_MODIFY'; // Name of trigger action code to execute when we modify record
@ -156,8 +179,7 @@ if (empty($reshook))
// Action to build doc
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
if ($action == 'classin' && $permissiontoadd)
{
if ($action == 'classin' && $permissiontoadd) {
$object->setProject(GETPOST('projectid', 'int'));
}
if ($action == 'confirm_decline' && $confirm == 'yes' && $permissiontoadd) {
@ -173,8 +195,7 @@ if (empty($reshook))
$action = 'makeofferordecline';
} else {
// prevent browser refresh from closing proposal several times
if ($object->status == $object::STATUS_VALIDATED)
{
if ($object->status == $object::STATUS_VALIDATED) {
$db->begin();
if (GETPOST('status', 'int') == $object::STATUS_REFUSED) {
@ -189,8 +210,7 @@ if (empty($reshook))
}
}
if (!$error)
{
if (!$error) {
$db->commit();
} else {
$db->rollback();
@ -205,8 +225,7 @@ if (empty($reshook))
$action = 'makeofferordecline';
} else {
// prevent browser refresh from closing proposal several times
if ($object->status == $object::STATUS_CONTRACT_PROPOSED)
{
if ($object->status == $object::STATUS_CONTRACT_PROPOSED) {
$db->begin();
if (GETPOST('status', 'int') == $object::STATUS_CONTRACT_REFUSED) {
@ -221,8 +240,7 @@ if (empty($reshook))
}
}
if (!$error)
{
if (!$error) {
$db->commit();
} else {
$db->rollback();
@ -306,15 +324,18 @@ jQuery(document).ready(function() {
// Part to create
if ($action == 'create')
{
if ($action == 'create') {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("RecruitmentCandidature")), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
if ($backtopage) {
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
}
if ($backtopageforcancel) {
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
}
print dol_get_fiche_head(array(), '');
@ -345,16 +366,19 @@ if ($action == 'create')
}
// Part to edit record
if (($id || $ref) && $action == 'edit')
{
if (($id || $ref) && $action == 'edit') {
print load_fiche_titre($langs->trans("RecruitmentCandidature"), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
if ($backtopage) {
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
}
if ($backtopageforcancel) {
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
}
print dol_get_fiche_head();
@ -378,8 +402,7 @@ if (($id || $ref) && $action == 'edit')
}
// Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
$res = $object->fetch_optionals();
$head = recruitmentcandidaturePrepareHead($object);
@ -402,8 +425,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
if ($action == 'makeofferordecline')
{
if ($action == 'makeofferordecline') {
$langs->load("propal");
//Form to close proposal (signed or not)
@ -417,8 +439,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'confirm_makeofferordecline', $formquestion, '', 1, 250);
}
if ($action == 'closeas')
{
if ($action == 'closeas') {
$langs->load("propal");
//Form to close proposal (signed or not)
@ -440,7 +461,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$login = dol_buildlogin($object->lastname, $object->firstname);
}
if (empty($login)) $login = strtolower(substr($object->firstname, 0, 4)).strtolower(substr($object->lastname, 0, 4));
if (empty($login)) {
$login = strtolower(substr($object->firstname, 0, 4)).strtolower(substr($object->lastname, 0, 4));
}
// Create a form array
$formquestion = array(
@ -453,8 +476,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Call Hook formConfirm
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
if (empty($reshook)) {
$formconfirm .= $hookmanager->resPrint;
} elseif ($reshook > 0) {
$formconfirm = $hookmanager->resPrint;
}
// Print form confirm
print $formconfirm;
@ -534,8 +560,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
* Lines
*/
if (!empty($object->table_element_line))
{
if (!empty($object->table_element_line)) {
// Show object lines
$result = $object->getLinesArray();
@ -551,21 +576,17 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
print '<div class="div-table-responsive-no-min">';
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
print '<table id="tablelines" class="noborder noshadow" width="100%">';
}
if (!empty($object->lines))
{
if (!empty($object->lines)) {
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
}
// Form to add new line
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
{
if ($action != 'editline')
{
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
if ($action != 'editline') {
// Add products/services form
$object->formAddObjectLine(1, $mysoc, $soc);
@ -574,8 +595,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
}
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
print '</table>';
}
print '</div>';
@ -590,39 +610,34 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="tabsAction">'."\n";
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Send
if (empty($user->socid)) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&sendto='.urlencode($object->email).'#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n";
}
// Back to draft
if ($object->status == $object::STATUS_VALIDATED)
{
if ($permissiontoadd)
{
if ($object->status == $object::STATUS_VALIDATED) {
if ($permissiontoadd) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
}
}
// Modify
if ($permissiontoadd)
{
if ($permissiontoadd) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n";
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
}
// Validate
if ($object->status == $object::STATUS_DRAFT)
{
if ($permissiontoadd)
{
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0))
{
if ($object->status == $object::STATUS_DRAFT) {
if ($permissiontoadd) {
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes">'.$langs->trans("Validate").'</a>';
} else {
$langs->load("errors");
@ -632,32 +647,26 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
// Make offer - Refuse - Decline
if ($object->status >= $object::STATUS_VALIDATED && $object->status < $object::STATUS_CONTRACT_PROPOSED)
{
if ($permissiontoadd)
{
if ($object->status >= $object::STATUS_VALIDATED && $object->status < $object::STATUS_CONTRACT_PROPOSED) {
if ($permissiontoadd) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=makeofferordecline">'.$langs->trans("MakeOffer").' / '.$langs->trans("Decline").'</a>';
}
}
// Contract refused / accepted
if ($object->status == $object::STATUS_CONTRACT_PROPOSED)
{
if ($permissiontoadd)
{
if ($object->status == $object::STATUS_CONTRACT_PROPOSED) {
if ($permissiontoadd) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=closeas">'.$langs->trans("Accept").' / '.$langs->trans("Decline").'</a>';
}
}
// Clone
if ($permissiontoadd)
{
if ($permissiontoadd) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=recruitmentcandidature">'.$langs->trans("ToClone").'</a>'."\n";
}
// Button to convert into a user
if ($object->status == $object::STATUS_CONTRACT_SIGNED)
{
if ($object->status == $object::STATUS_CONTRACT_SIGNED) {
if ($user->rights->user->user->creer) {
// TODO Check if a user already exists
$useralreadyexists = 0;
@ -672,21 +681,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
// Cancel
if ($permissiontoadd)
{
if ($object->status == $object::STATUS_VALIDATED)
{
if ($permissiontoadd) {
if ($object->status == $object::STATUS_VALIDATED) {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close">'.$langs->trans("Cancel").'</a>'."\n";
}
elseif ($object->status == $object::STATUS_REFUSED || $object->status == $object::STATUS_CANCELED || $object->status == $object::STATUS_CONTRACT_REFUSED)
{
} elseif ($object->status == $object::STATUS_REFUSED || $object->status == $object::STATUS_CANCELED || $object->status == $object::STATUS_CONTRACT_REFUSED) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken().'">'.$langs->trans("Re-Open").'</a>'."\n";
}
}
// Delete (need delete permission, or if draft, just need create/modify permission)
if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd))
{
if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)) {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n";
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
@ -701,8 +705,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$action = 'presend';
}
if ($action != 'presend')
{
if ($action != 'presend') {
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
@ -741,7 +744,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
//Select mail models is same action as presend
if (GETPOST('modelselected')) $action = 'presend';
if (GETPOST('modelselected')) {
$action = 'presend';
}
// Presend form
$modelmail = 'recruitmentcandidature_send';

View File

@ -25,17 +25,33 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -58,12 +74,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
//if (! $sortfield) $sortfield="position_name";
// Initialize technical objects
@ -77,7 +99,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) $upload_dir = $conf->recruitment->multidir_output[$object->entity ? $object->entity : $conf->entity]."/recruitmentcandidature/".get_exdir(0, 0, 0, 1, $object);
if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->recruitment->multidir_output[$object->entity ? $object->entity : $conf->entity]."/recruitmentcandidature/".get_exdir(0, 0, 0, 1, $object);
}
// Security check - Protection if external user
//if ($user->socid > 0) accessforbidden();
@ -106,8 +130,7 @@ $help_url = '';
//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
if ($object->id)
{
if ($object->id) {
/*
* Show tabs
*/
@ -119,8 +142,7 @@ if ($object->id)
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
foreach ($filearray as $key => $file)
{
foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}

View File

@ -44,17 +44,33 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@ -86,7 +102,9 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -104,28 +122,33 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) {
$sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
}
if (!$sortorder) {
$sortorder = "ASC";
}
// Initialize array of search criterias
$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
$search = array();
foreach ($object->fields as $key => $val)
{
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha') !== '') {
$search[$key] = GETPOST('search_'.$key, 'alpha');
}
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
foreach ($object->fields as $key => $val)
{
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
foreach ($object->fields as $key => $val) {
if ($val['searchall']) {
$fieldstosearchall['t.'.$key] = $val['label'];
}
}
// Definition of fields for list
$arrayfields = array();
foreach ($object->fields as $key => $val)
{
foreach ($object->fields as $key => $val) {
// If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) {
$visible = dol_eval($val['visible'], 1);
@ -138,10 +161,8 @@ foreach ($object->fields as $key => $val)
}
}
// Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array(
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
@ -160,10 +181,11 @@ $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write;
$permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete;
// Security check
if (empty($conf->recruitment->enabled)) accessforbidden('Module not enabled');
if (empty($conf->recruitment->enabled)) {
accessforbidden('Module not enabled');
}
$socid = 0;
if ($user->socid > 0) // Protection if external user
{
if ($user->socid > 0) { // Protection if external user
//$socid = $user->socid;
accessforbidden();
}
@ -176,31 +198,33 @@ if ($user->socid > 0) // Protection if external user
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
foreach ($object->fields as $key => $val)
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
foreach ($object->fields as $key => $val) {
$search[$key] = '';
}
$toselect = '';
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
{
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
@ -229,13 +253,14 @@ $title = $langs->trans('ListOfCandidatures');
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ';
foreach ($object->fields as $key => $val)
{
foreach ($object->fields as $key => $val) {
$sql .= 't.'.$key.', ';
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
}
}
// Add fields from hooks
$parameters = array();
@ -243,20 +268,32 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
else $sql .= " WHERE 1 = 1";
foreach ($search as $key => $val)
{
if ($key == 'status' && $search[$key] == -1) continue;
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
}
if ($object->ismultientitymanaged == 1) {
$sql .= " WHERE t.entity IN (".getEntity($object->element).")";
} else {
$sql .= " WHERE 1 = 1";
}
foreach ($search as $key => $val) {
if ($key == 'status' && $search[$key] == -1) {
continue;
}
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
if ($search[$key] == '-1') $search[$key] = '';
if ($search[$key] == '-1') {
$search[$key] = '';
}
$mode_search = 2;
}
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
if ($search[$key] != '') {
$sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
}
}
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@ -286,26 +323,24 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
{
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
$page = 0;
$offset = 0;
}
}
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
{
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
$num = $nbtotalofrecords;
} else {
if ($limit) $sql .= $db->plimit($limit + 1, $offset);
if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql);
if (!$resql)
{
if (!$resql) {
dol_print_error($db);
exit;
}
@ -314,8 +349,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit
}
// Direct jump if only one record found
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page)
{
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?id='.$id);
@ -346,14 +380,24 @@ jQuery(document).ready(function() {
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
foreach ($search as $key => $val)
{
if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
else $param .= '&search_'.$key.'='.urlencode($search[$key]);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
foreach ($search as $key => $val) {
if (is_array($search[$key]) && count($search[$key])) {
foreach ($search[$key] as $skey) {
$param .= '&search_'.$key.'[]='.urlencode($skey);
}
} else {
$param .= '&search_'.$key.'='.urlencode($search[$key]);
}
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -364,12 +408,18 @@ $arrayofmassactions = array(
//'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
);
if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if ($permissiontodelete) {
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -389,9 +439,10 @@ $objecttmp = new RecruitmentCandidature($db);
$trackid = 'xxxx'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($search_all)
{
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
if ($search_all) {
foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val);
}
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
}
@ -402,11 +453,13 @@ $moreforfilter.= '</div>';*/
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
if (empty($reshook)) {
$moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if (!empty($moreforfilter))
{
if (!empty($moreforfilter)) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
@ -423,20 +476,26 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
foreach ($object->fields as $key => $val)
{
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
if (!empty($arrayfields['t.'.$key]['checked']))
{
if ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
elseif (strpos($val['type'], 'integer:') === 0) {
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
} elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
}
print '</td>';
}
}
@ -458,15 +517,18 @@ print '</tr>'."\n";
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
foreach ($object->fields as $key => $val)
{
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
if (!empty($arrayfields['t.'.$key]['checked']))
{
if ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
}
}
@ -483,11 +545,11 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
{
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
{
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
if (preg_match('/\$object/', $val)) {
$needToFetchEachLine++; // There is at least one compute field that use $object
}
}
}
@ -496,38 +558,51 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
while ($i < ($limit ? min($num, $limit) : $num))
{
while ($i < ($limit ? min($num, $limit) : $num)) {
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
if (empty($obj)) {
break; // Should not happen
}
// Store properties in $object
$object->setVarsFromFetchObj($obj);
// Show here line of result
print '<tr class="oddeven">';
foreach ($object->fields as $key => $val)
{
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
}
if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
if (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif ($key == 'ref') {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
}
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
if (!empty($arrayfields['t.'.$key]['checked']))
{
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
if ($key == 'status') print $object->getLibStatut(5);
else print $object->showOutputField($val, $key, $object->$key, '');
if ($key == 'status') {
print $object->getLibStatut(5);
} else {
print $object->showOutputField($val, $key, $object->$key, '');
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!empty($val['isameasure']))
{
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
if (!$i) {
$totalarray['nbfield']++;
}
if (!empty($val['isameasure'])) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
$totalarray['val']['t.'.$key] += $object->$key;
}
}
@ -540,14 +615,17 @@ while ($i < ($limit ? min($num, $limit) : $num))
print $hookmanager->resPrint;
// Action column
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($object->id, $arrayofselected)) $selected = 1;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n";
@ -558,10 +636,13 @@ while ($i < ($limit ? min($num, $limit) : $num))
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
if ($num == 0)
{
if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
@ -577,10 +658,11 @@ print '</div>'."\n";
print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
{
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
$hidegeneratedfilelistifempty = 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);

View File

@ -25,17 +25,33 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
dol_include_once('/recruitment/class/recruitmentcandidature.class.php');
dol_include_once('/recruitment/lib/recruitment_recruitmentcandidature.lib.php');
@ -65,7 +81,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
}
$permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php
$permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php
@ -89,8 +107,7 @@ $form = new Form($db);
$help_url = '';
llxHeader('', $langs->trans('RecruitmentCandidature'), $help_url);
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$object->fetch_thirdparty();
$head = recruitmentCandidaturePrepareHead($object);

View File

@ -38,8 +38,7 @@ $action = GETPOST('action', 'aZ09');
// Security check
//if (! $user->rights->recruitment->myobject->read) accessforbidden();
$socid = GETPOST('socid', 'int');
if (isset($user->socid) && $user->socid > 0)
{
if (isset($user->socid) && $user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@ -75,16 +74,14 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
* Statistics
*/
if ($conf->use_javascript_ajax)
{
if ($conf->use_javascript_ajax) {
$sql = "SELECT COUNT(t.rowid) as nb, status";
$sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as t";
$sql .= " GROUP BY t.status";
$sql .= " ORDER BY t.status ASC";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
@ -95,11 +92,9 @@ if ($conf->use_javascript_ajax)
include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
if ($obj)
{
if ($obj) {
$vals[$obj->status] = $obj->nb;
$totalnb += $obj->nb;
@ -112,24 +107,29 @@ if ($conf->use_javascript_ajax)
print '<table class="noborder nohover centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("JobPositions").'</th></tr>'."\n";
$listofstatus = array(0, 1, 3, 9);
foreach ($listofstatus as $status)
{
foreach ($listofstatus as $status) {
$dataseries[] = array(dol_html_entity_decode($staticrecruitmentjobposition->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5), (isset($vals[$status]) ? (int) $vals[$status] : 0));
if ($status == RecruitmentJobPosition::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
if ($status == RecruitmentJobPosition::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus4;
if ($status == RecruitmentJobPosition::STATUS_RECRUITED) $colorseries[$status] = $badgeStatus6;
if ($status == RecruitmentJobPosition::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9;
if ($status == RecruitmentJobPosition::STATUS_DRAFT) {
$colorseries[$status] = '-'.$badgeStatus0;
}
if ($status == RecruitmentJobPosition::STATUS_VALIDATED) {
$colorseries[$status] = $badgeStatus4;
}
if ($status == RecruitmentJobPosition::STATUS_RECRUITED) {
$colorseries[$status] = $badgeStatus6;
}
if ($status == RecruitmentJobPosition::STATUS_CANCELED) {
$colorseries[$status] = $badgeStatus9;
}
if (empty($conf->use_javascript_ajax))
{
if (empty($conf->use_javascript_ajax)) {
print '<tr class="oddeven">';
print '<td>'.$staticrecruitmentjobposition->LibStatut($status, 0).'</td>';
print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
print "</tr>\n";
}
}
if ($conf->use_javascript_ajax)
{
if ($conf->use_javascript_ajax) {
print '<tr><td class="center" colspan="2">';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@ -159,8 +159,7 @@ if ($conf->use_javascript_ajax)
$sql .= " ORDER BY t.status ASC";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
@ -171,11 +170,9 @@ if ($conf->use_javascript_ajax)
include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
if ($obj)
{
if ($obj) {
$vals[$obj->status] = $obj->nb;
$totalnb += $obj->nb;
@ -188,26 +185,35 @@ if ($conf->use_javascript_ajax)
print '<table class="noborder nohover centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Candidatures").'</th></tr>'."\n";
$listofstatus = array(0, 1, 3, 5, 8, 9);
foreach ($listofstatus as $status)
{
foreach ($listofstatus as $status) {
$dataseries[] = array(dol_html_entity_decode($staticrecruitmentcandidature->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5), (isset($vals[$status]) ? (int) $vals[$status] : 0));
if ($status == RecruitmentCandidature::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
if ($status == RecruitmentCandidature::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1;
if ($status == RecruitmentCandidature::STATUS_CONTRACT_PROPOSED) $colorseries[$status] = $badgeStatus4;
if ($status == RecruitmentCandidature::STATUS_CONTRACT_SIGNED) $colorseries[$status] = $badgeStatus5;
if ($status == RecruitmentCandidature::STATUS_REFUSED) $colorseries[$status] = $badgeStatus9;
if ($status == RecruitmentCandidature::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9;
if ($status == RecruitmentCandidature::STATUS_DRAFT) {
$colorseries[$status] = '-'.$badgeStatus0;
}
if ($status == RecruitmentCandidature::STATUS_VALIDATED) {
$colorseries[$status] = $badgeStatus1;
}
if ($status == RecruitmentCandidature::STATUS_CONTRACT_PROPOSED) {
$colorseries[$status] = $badgeStatus4;
}
if ($status == RecruitmentCandidature::STATUS_CONTRACT_SIGNED) {
$colorseries[$status] = $badgeStatus5;
}
if ($status == RecruitmentCandidature::STATUS_REFUSED) {
$colorseries[$status] = $badgeStatus9;
}
if ($status == RecruitmentCandidature::STATUS_CANCELED) {
$colorseries[$status] = $badgeStatus9;
}
if (empty($conf->use_javascript_ajax))
{
if (empty($conf->use_javascript_ajax)) {
print '<tr class="oddeven">';
print '<td>'.$staticrecruitmentcandidature->LibStatut($status, 0).'</td>';
print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
print "</tr>\n";
}
}
if ($conf->use_javascript_ajax)
{
if ($conf->use_javascript_ajax) {
print '<tr><td class="center" colspan="2">';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@ -321,22 +327,26 @@ $NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
// Last modified job position
if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read)
{
if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) {
$sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status, COUNT(rc.rowid) as nbapplications";
$sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc ON rc.fk_recruitmentjobposition = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.fk_soc = $socid";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid) {
$sql .= " AND s.fk_soc = $socid";
}
$sql .= " GROUP BY s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status";
$sql .= " ORDER BY s.tms DESC";
$sql .= $db->plimit($max, 0);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
@ -351,10 +361,8 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme
print '</th>';
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentjobposition_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
print '</tr>';
if ($num)
{
while ($i < $num)
{
if ($num) {
while ($i < $num) {
$objp = $db->fetch_object($resql);
$staticrecruitmentjobposition->id = $objp->rowid;
$staticrecruitmentjobposition->ref = $objp->ref;
@ -390,21 +398,25 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme
}
// Last modified job position
if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read)
{
if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) {
$sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status";
$sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.fk_soc = $socid";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid) {
$sql .= " AND s.fk_soc = $socid";
}
$sql .= " ORDER BY rc.tms DESC";
$sql .= $db->plimit($max, 0);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
@ -416,10 +428,8 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme
print '</th>';
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
print '</tr>';
if ($num)
{
while ($i < $num)
{
if ($num) {
while ($i < $num) {
$objp = $db->fetch_object($resql);
$staticrecruitmentcandidature->id = $objp->rowid;
$staticrecruitmentcandidature->ref = $objp->ref;

View File

@ -25,17 +25,33 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
@ -56,7 +72,9 @@ $backtopage = GETPOST('backtopage', 'alpha');
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0';
if (!count($actioncode)) {
$actioncode = '0';
}
} else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
}
@ -66,12 +84,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = 'a.datep,a.id';
if (!$sortorder) $sortorder = 'DESC,DESC';
if (!$sortfield) {
$sortfield = 'a.datep,a.id';
}
if (!$sortorder) {
$sortorder = 'DESC,DESC';
}
// Initialize technical objects
$object = new RecruitmentJobPosition($db);
@ -83,7 +107,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
}
// Security check - Protection if external user
//if ($user->socid > 0) accessforbidden();
@ -99,20 +125,19 @@ $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; //
$parameters = array('id'=>$id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Cancel
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
{
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$actioncode = '';
$search_agenda_label = '';
}
@ -126,14 +151,15 @@ if (empty($reshook))
$form = new Form($db);
if ($object->id > 0)
{
if ($object->id > 0) {
$title = $langs->trans("Agenda");
//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
$help_url = '';
llxHeader('', $title, $help_url);
if (!empty($conf->notification->enabled)) $langs->load("mails");
if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = recruitmentjobpositionPrepareHead($object);
@ -152,15 +178,14 @@ if ($object->id > 0)
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
*/
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= $langs->trans('Project').' ';
if ($permissiontoadd)
{
if ($action != 'classify')
if ($permissiontoadd) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';
$morehtmlref .= ' : ';
}
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
@ -206,10 +231,11 @@ if ($object->id > 0)
$out = '&origin='.$object->element.'@recruitment&originid='.$object->id;
$permok = $user->rights->agenda->myactions->create;
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok)
{
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
//$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
if (get_class($objthirdparty) == 'Societe') $out .= '&amp;socid='.$objthirdparty->id;
if (get_class($objthirdparty) == 'Societe') {
$out .= '&amp;socid='.$objthirdparty->id;
}
$out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;backtopage=1&amp;percentage=-1';
//$out.=$langs->trans("AddAnAction").' ';
//$out.=img_picto($langs->trans("AddAnAction"),'filenew');
@ -219,10 +245,8 @@ if ($object->id > 0)
print '<div class="tabsAction">';
if (!empty($conf->agenda->enabled))
{
if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
{
if (!empty($conf->agenda->enabled)) {
if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
@ -231,11 +255,14 @@ if ($object->id > 0)
print '</div>';
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
{
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$param = '&id='.$object->id.'&socid='.$socid;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
//print load_fiche_titre($langs->trans("ActionsOnRecruitmentJobPosition"), '', '');

View File

@ -44,17 +44,33 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
@ -91,12 +107,15 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha');
$search = array();
foreach ($object->fields as $key => $val)
{
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha')) {
$search[$key] = GETPOST('search_'.$key, 'alpha');
}
}
if (empty($action) && empty($id) && empty($ref)) $action = 'view';
if (empty($action) && empty($id) && empty($ref)) {
$action = 'view';
}
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
@ -124,18 +143,22 @@ $upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $obje
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
$error = 0;
$backurlforlist = dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1);
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
$backtopage = $backurlforlist;
} else {
$backtopage = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
}
}
}
$triggermodname = 'RECRUITMENT_RECRUITMENTJOBPOSITION_MODIFY'; // Name of trigger action code to execute when we modify record
@ -155,12 +178,10 @@ if (empty($reshook))
// Action to build doc
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
if ($action == 'set_thirdparty' && $permissiontoadd)
{
if ($action == 'set_thirdparty' && $permissiontoadd) {
$object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'RECRUITMENTJOBPOSITION_MODIFY');
}
if ($action == 'classin' && $permissiontoadd)
{
if ($action == 'classin' && $permissiontoadd) {
$object->setProject(GETPOST('projectid', 'int'));
}
@ -189,18 +210,23 @@ $help_url = '';
llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create')
{
if ($action == 'create') {
print load_fiche_titre($langs->trans("NewPositionToBeFilled"), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
if ($backtopage) {
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
}
if ($backtopageforcancel) {
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
}
// Set some default values
if (!GETPOSTISSET('fk_user_recruiter')) $_POST['fk_user_recruiter'] = $user->id;
if (!GETPOSTISSET('fk_user_recruiter')) {
$_POST['fk_user_recruiter'] = $user->id;
}
print dol_get_fiche_head(array(), '');
@ -228,16 +254,19 @@ if ($action == 'create')
}
// Part to edit record
if (($id || $ref) && $action == 'edit')
{
if (($id || $ref) && $action == 'edit') {
print load_fiche_titre($langs->trans("PositionToBeFilled"), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
if ($backtopage) {
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
}
if ($backtopageforcancel) {
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
}
print dol_get_fiche_head();
@ -261,8 +290,7 @@ if (($id || $ref) && $action == 'edit')
}
// Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
$res = $object->fetch_optionals();
$head = recruitmentjobpositionPrepareHead($object);
@ -271,13 +299,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = '';
// Confirmation to delete
if ($action == 'delete')
{
if ($action == 'delete') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentJobPosition'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
}
// Confirmation to delete line
if ($action == 'deleteline')
{
if ($action == 'deleteline') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
}
// Clone confirmation
@ -288,8 +314,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
// Confirmation of action xxxx
if ($action == 'xxx')
{
if ($action == 'xxx') {
$formquestion = array();
/*
$forcecombo=0;
@ -307,8 +332,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Call Hook formConfirm
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
if (empty($reshook)) {
$formconfirm .= $hookmanager->resPrint;
} elseif ($reshook > 0) {
$formconfirm = $hookmanager->resPrint;
}
// Print form confirm
print $formconfirm;
@ -327,13 +355,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
*/
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= $langs->trans('Project').' ';
if ($permissiontoadd)
{
if ($action != 'classify') $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
if ($permissiontoadd) {
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
}
$morehtmlref .= ' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
@ -389,8 +417,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
* Lines
*/
if (!empty($object->table_element_line))
{
if (!empty($object->table_element_line)) {
// Show object lines
$result = $object->getLinesArray();
@ -406,21 +433,17 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
print '<div class="div-table-responsive-no-min">';
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
print '<table id="tablelines" class="noborder noshadow" width="100%">';
}
if (!empty($object->lines))
{
if (!empty($object->lines)) {
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
}
// Form to add new line
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
{
if ($action != 'editline')
{
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
if ($action != 'editline') {
// Add products/services form
$object->formAddObjectLine(1, $mysoc, $soc);
@ -429,8 +452,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
}
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
print '</table>';
}
print '</div>';

View File

@ -44,17 +44,33 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
@ -91,12 +107,15 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha');
$search = array();
foreach ($object->fields as $key => $val)
{
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha')) {
$search[$key] = GETPOST('search_'.$key, 'alpha');
}
}
if (empty($action) && empty($id) && empty($ref)) $action = 'view';
if (empty($action) && empty($id) && empty($ref)) {
$action = 'view';
}
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
@ -126,18 +145,22 @@ $usercanclose = $permissiontoadd;
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
$error = 0;
$backurlforlist = dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1);
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
$backtopage = $backurlforlist;
} else {
$backtopage = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
}
}
}
$triggermodname = 'RECRUITMENT_RECRUITMENTJOBPOSITION_MODIFY'; // Name of trigger action code to execute when we modify record
@ -157,12 +180,10 @@ if (empty($reshook))
// Action to build doc
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
if ($action == 'set_thirdparty' && $permissiontoadd)
{
if ($action == 'set_thirdparty' && $permissiontoadd) {
$object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'RECRUITMENTJOBPOSITION_MODIFY');
}
if ($action == 'classin' && $permissiontoadd)
{
if ($action == 'classin' && $permissiontoadd) {
$object->setProject(GETPOST('projectid', 'int'));
}
if ($action == 'confirm_closeas' && $usercanclose && !GETPOST('cancel', 'alpha')) {
@ -171,19 +192,16 @@ if (empty($reshook))
$action = 'closeas';
} else {
// prevent browser refresh from closing proposal several times
if ($object->status == $object::STATUS_VALIDATED)
{
if ($object->status == $object::STATUS_VALIDATED) {
$db->begin();
$result = $object->cloture($user, GETPOST('status', 'int'), GETPOST('note_private', 'restricthtml'));
if ($result < 0)
{
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
if (!$error)
{
if (!$error) {
$db->commit();
} else {
$db->rollback();
@ -217,18 +235,23 @@ $help_url = '';
llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create')
{
if ($action == 'create') {
print load_fiche_titre($langs->trans("NewPositionToBeFilled"), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
if ($backtopage) {
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
}
if ($backtopageforcancel) {
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
}
// Set some default values
if (!GETPOSTISSET('fk_user_recruiter')) $_POST['fk_user_recruiter'] = $user->id;
if (!GETPOSTISSET('fk_user_recruiter')) {
$_POST['fk_user_recruiter'] = $user->id;
}
print dol_get_fiche_head(array(), '');
@ -256,16 +279,19 @@ if ($action == 'create')
}
// Part to edit record
if (($id || $ref) && $action == 'edit')
{
if (($id || $ref) && $action == 'edit') {
print load_fiche_titre($langs->trans("PositionToBeFilled"), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
if ($backtopage) {
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
}
if ($backtopageforcancel) {
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
}
print dol_get_fiche_head();
@ -289,8 +315,7 @@ if (($id || $ref) && $action == 'edit')
}
// Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
$res = $object->fetch_optionals();
$head = recruitmentjobpositionPrepareHead($object);
@ -299,13 +324,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = '';
// Confirmation to delete
if ($action == 'delete')
{
if ($action == 'delete') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentJobPosition'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
}
// Confirmation to delete line
if ($action == 'deleteline')
{
if ($action == 'deleteline') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
}
// Clone confirmation
@ -314,8 +337,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formquestion = array();
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
if ($action == 'closeas')
{
if ($action == 'closeas') {
//Form to close proposal (signed or not)
$formquestion = array(
array('type' => 'select', 'name' => 'status', 'label' => '<span class="fieldrequired">'.$langs->trans("CloseAs").'</span>', 'values' => array(3=>$object->LibStatut($object::STATUS_RECRUITED), 9=>$object->LibStatut($object::STATUS_CANCELED))),
@ -337,8 +359,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Call Hook formConfirm
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
if (empty($reshook)) {
$formconfirm .= $hookmanager->resPrint;
} elseif ($reshook > 0) {
$formconfirm = $hookmanager->resPrint;
}
// Print form confirm
print $formconfirm;
@ -357,13 +382,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
*/
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= $langs->trans('Project').' ';
if ($permissiontoadd)
{
if ($action != 'classify') $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
if ($permissiontoadd) {
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
}
$morehtmlref .= ' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
@ -419,8 +444,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
* Lines
*/
if (!empty($object->table_element_line))
{
if (!empty($object->table_element_line)) {
// Show object lines
$result = $object->getLinesArray();
@ -436,21 +460,17 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
print '<div class="div-table-responsive-no-min">';
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
print '<table id="tablelines" class="noborder noshadow" width="100%">';
}
if (!empty($object->lines))
{
if (!empty($object->lines)) {
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
}
// Form to add new line
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
{
if ($action != 'editline')
{
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
if ($action != 'editline') {
// Add products/services form
$object->formAddObjectLine(1, $mysoc, $soc);
@ -459,8 +479,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
}
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
print '</table>';
}
print '</div>';
@ -475,10 +494,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="tabsAction">'."\n";
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Send
if (empty($user->socid)) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n";
@ -486,8 +506,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Back to draft
if ($object->status == $object::STATUS_VALIDATED) {
if ($permissiontoadd)
{
if ($permissiontoadd) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
}
}
@ -502,8 +521,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Validate
if ($object->status == $object::STATUS_DRAFT) {
if ($permissiontoadd) {
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0))
{
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes">'.$langs->trans("Validate").'</a>';
} else {
$langs->load("errors");
@ -535,8 +553,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable">'.$langs->trans("Enable").'</a>'."\n";
}
}*/
if ($permissiontoadd)
{
if ($permissiontoadd) {
if ($object->status == $object::STATUS_CANCELED) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes">'.$langs->trans("Re-Open").'</a>'."\n";
}
@ -558,8 +575,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$action = 'presend';
}
if ($action != 'presend')
{
if ($action != 'presend') {
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
@ -581,8 +597,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
// Show link to public job page
if ($object->status != RecruitmentJobPosition::STATUS_DRAFT)
{
if ($object->status != RecruitmentJobPosition::STATUS_DRAFT) {
print '<br><!-- Link to go on public job page -->'."\n";
// Load translation files required by the page
$langs->loadLangs(array('recruitment'));
@ -614,7 +629,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
//Select mail models is same action as presend
if (GETPOST('modelselected')) $action = 'presend';
if (GETPOST('modelselected')) {
$action = 'presend';
}
// Presend form
$modelmail = 'recruitmentjobposition';

View File

@ -25,17 +25,33 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -58,12 +74,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
//if (! $sortfield) $sortfield="position_name";
// Initialize technical objects
@ -77,7 +99,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) $upload_dir = $conf->recruitment->multidir_output[$object->entity ? $object->entity : $conf->entity]."/recruitmentjobposition/".get_exdir(0, 0, 0, 1, $object);
if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->recruitment->multidir_output[$object->entity ? $object->entity : $conf->entity]."/recruitmentjobposition/".get_exdir(0, 0, 0, 1, $object);
}
// Security check - Protection if external user
//if ($user->socid > 0) accessforbidden();
@ -106,8 +130,7 @@ $help_url = '';
//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
if ($object->id)
{
if ($object->id) {
/*
* Show tabs
*/
@ -119,8 +142,7 @@ if ($object->id)
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
foreach ($filearray as $key => $file)
{
foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}
@ -137,15 +159,14 @@ if ($object->id)
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
*/
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= $langs->trans('Project').' ';
if ($permissiontoadd)
{
if ($action != 'classify')
if ($permissiontoadd) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';
$morehtmlref .= ' : ';
}
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';

View File

@ -44,17 +44,33 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@ -86,7 +102,9 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -104,28 +122,33 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) {
$sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
}
if (!$sortorder) {
$sortorder = "ASC";
}
// Initialize array of search criterias
$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
$search = array();
foreach ($object->fields as $key => $val)
{
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha') !== '') {
$search[$key] = GETPOST('search_'.$key, 'alpha');
}
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
foreach ($object->fields as $key => $val)
{
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
foreach ($object->fields as $key => $val) {
if ($val['searchall']) {
$fieldstosearchall['t.'.$key] = $val['label'];
}
}
// Definition of fields for list
$arrayfields = array();
foreach ($object->fields as $key => $val)
{
foreach ($object->fields as $key => $val) {
// If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) {
$visible = dol_eval($val['visible'], 1);
@ -138,10 +161,8 @@ foreach ($object->fields as $key => $val)
}
}
// Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array(
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
@ -161,10 +182,11 @@ $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write;
$permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete;
// Security check
if (empty($conf->recruitment->enabled)) accessforbidden('Module not enabled');
if (empty($conf->recruitment->enabled)) {
accessforbidden('Module not enabled');
}
$socid = 0;
if ($user->socid > 0) // Protection if external user
{
if ($user->socid > 0) { // Protection if external user
//$socid = $user->socid;
accessforbidden();
}
@ -177,31 +199,33 @@ if ($user->socid > 0) // Protection if external user
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
foreach ($object->fields as $key => $val)
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
foreach ($object->fields as $key => $val) {
$search[$key] = '';
}
$toselect = '';
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
{
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
@ -230,13 +254,14 @@ $title = $langs->trans('ListOfPositionsToBeFilled');
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ';
foreach ($object->fields as $key => $val)
{
foreach ($object->fields as $key => $val) {
$sql .= 't.'.$key.', ';
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
}
}
// Add fields from hooks
$parameters = array();
@ -246,20 +271,32 @@ $sql = preg_replace('/,\s*$/', '', $sql);
$sql .= ", COUNT(rc.rowid) as nbapplications";
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc ON rc.fk_recruitmentjobposition = t.rowid";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
else $sql .= " WHERE 1 = 1";
foreach ($search as $key => $val)
{
if ($key == 'status' && $search[$key] == -1) continue;
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
}
if ($object->ismultientitymanaged == 1) {
$sql .= " WHERE t.entity IN (".getEntity($object->element).")";
} else {
$sql .= " WHERE 1 = 1";
}
foreach ($search as $key => $val) {
if ($key == 'status' && $search[$key] == -1) {
continue;
}
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
if ($search[$key] == '-1') $search[$key] = '';
if ($search[$key] == '-1') {
$search[$key] = '';
}
$mode_search = 2;
}
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
if ($search[$key] != '') {
$sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
}
}
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@ -270,13 +307,14 @@ $sql .= $hookmanager->resPrint;
/* If a group by is required */
$sql .= " GROUP BY ";
foreach ($object->fields as $key => $val)
{
foreach ($object->fields as $key => $val) {
$sql .= 't.'.$key.', ';
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
}
}
// Add where from hooks
$parameters = array();
@ -288,26 +326,24 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
{
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
$page = 0;
$offset = 0;
}
}
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
{
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
$num = $nbtotalofrecords;
} else {
if ($limit) $sql .= $db->plimit($limit + 1, $offset);
if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql);
if (!$resql)
{
if (!$resql) {
dol_print_error($db);
exit;
}
@ -316,8 +352,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit
}
// Direct jump if only one record found
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page)
{
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.$id);
@ -348,14 +383,24 @@ jQuery(document).ready(function() {
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
foreach ($search as $key => $val)
{
if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
else $param .= '&search_'.$key.'='.urlencode($search[$key]);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
foreach ($search as $key => $val) {
if (is_array($search[$key]) && count($search[$key])) {
foreach ($search[$key] as $skey) {
$param .= '&search_'.$key.'[]='.urlencode($skey);
}
} else {
$param .= '&search_'.$key.'='.urlencode($search[$key]);
}
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -366,12 +411,18 @@ $arrayofmassactions = array(
//'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
);
if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if ($permissiontodelete) {
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -391,9 +442,10 @@ $objecttmp = new RecruitmentJobPosition($db);
$trackid = 'recruitmentjobposition'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($search_all)
{
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
if ($search_all) {
foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val);
}
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
}
@ -404,11 +456,13 @@ $moreforfilter.= '</div>';*/
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
if (empty($reshook)) {
$moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if (!empty($moreforfilter))
{
if (!empty($moreforfilter)) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
@ -425,20 +479,26 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
foreach ($object->fields as $key => $val)
{
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
if (!empty($arrayfields['t.'.$key]['checked']))
{
if ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
elseif (strpos($val['type'], 'integer:') === 0) {
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
} elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
}
print '</td>';
}
}
@ -448,8 +508,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!empty($arrayfields['nbapplications']['checked']))
{
if (!empty($arrayfields['nbapplications']['checked'])) {
print '<td class="liste_titre"></td>';
}
// Action column
@ -463,15 +522,18 @@ print '</tr>'."\n";
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
foreach ($object->fields as $key => $val)
{
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
if (!empty($arrayfields['t.'.$key]['checked']))
{
if ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
}
}
@ -481,8 +543,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!empty($arrayfields['nbapplications']['checked']))
{
if (!empty($arrayfields['nbapplications']['checked'])) {
print '<td class="liste_titre">'.$langs->trans("Applications").'</td>';
}
// Action column
@ -492,11 +553,11 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
{
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
{
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
if (preg_match('/\$object/', $val)) {
$needToFetchEachLine++; // There is at least one compute field that use $object
}
}
}
@ -505,38 +566,51 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
while ($i < ($limit ? min($num, $limit) : $num))
{
while ($i < ($limit ? min($num, $limit) : $num)) {
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
if (empty($obj)) {
break; // Should not happen
}
// Store properties in $object
$object->setVarsFromFetchObj($obj);
// Show here line of result
print '<tr class="oddeven">';
foreach ($object->fields as $key => $val)
{
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
}
if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
if (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif ($key == 'ref') {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
}
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
if (!empty($arrayfields['t.'.$key]['checked']))
{
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
if ($key == 'status') print $object->getLibStatut(5);
else print $object->showOutputField($val, $key, $object->$key, '');
if ($key == 'status') {
print $object->getLibStatut(5);
} else {
print $object->showOutputField($val, $key, $object->$key, '');
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!empty($val['isameasure']))
{
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
if (!$i) {
$totalarray['nbfield']++;
}
if (!empty($val['isameasure'])) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
$totalarray['val']['t.'.$key] += $object->$key;
}
}
@ -547,20 +621,22 @@ while ($i < ($limit ? min($num, $limit) : $num))
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!empty($arrayfields['nbapplications']['checked']))
{
if (!empty($arrayfields['nbapplications']['checked'])) {
print '<td class="right">'.$obj->nbapplications.'</td>';
}
// Action column
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($object->id, $arrayofselected)) $selected = 1;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n";
@ -571,10 +647,13 @@ while ($i < ($limit ? min($num, $limit) : $num))
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
if ($num == 0)
{
if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
@ -590,10 +669,11 @@ print '</div>'."\n";
print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
{
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
$hidegeneratedfilelistifempty = 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);

View File

@ -25,17 +25,33 @@
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
dol_include_once('/recruitment/class/recruitmentjobposition.class.php');
dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php');
@ -65,7 +81,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
}
$permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php
$permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php
@ -89,8 +107,7 @@ $form = new Form($db);
$help_url = '';
llxHeader('', $langs->trans('RecruitmentJobPosition'), $help_url);
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$object->fetch_thirdparty();
$head = recruitmentjobpositionPrepareHead($object);
@ -110,15 +127,14 @@ if ($id > 0 || !empty($ref))
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
*/
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= $langs->trans('Project').' ';
if ($permissiontoadd)
{
if ($action != 'classify')
if ($permissiontoadd) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';
$morehtmlref .= ' : ';
}
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';

View File

@ -44,10 +44,11 @@ $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
if (GETPOST('actioncode', 'array'))
{
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0';
if (!count($actioncode)) {
$actioncode = '0';
}
} else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
}
@ -57,12 +58,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = 'a.datep,a.id';
if (!$sortorder) $sortorder = 'DESC,DESC';
if (!$sortfield) {
$sortfield = 'a.datep,a.id';
}
if (!$sortorder) {
$sortorder = 'DESC,DESC';
}
$object = new DolResource($db);
$object->fetch($id, $ref);
@ -73,8 +80,7 @@ $extrafields = new ExtraFields($db);
$hookmanager->initHooks(array('agendaresource'));
// Security check
if (!$user->rights->resource->read)
{
if (!$user->rights->resource->read) {
accessforbidden();
}
@ -85,20 +91,19 @@ if (!$user->rights->resource->read)
$parameters = array('id'=>$id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Cancel
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
{
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$actioncode = '';
$search_agenda_label = '';
}
@ -113,8 +118,7 @@ if (empty($reshook))
$contactstatic = new Contact($db);
$form = new Form($db);
if ($object->id > 0)
{
if ($object->id > 0) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
@ -122,10 +126,14 @@ if ($object->id > 0)
$picto = 'resource';
$title = $langs->trans("Agenda");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref." - ".$title;
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->ref." - ".$title;
}
llxHeader('', $title);
if (!empty($conf->notification->enabled)) $langs->load("mails");
if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$type = $langs->trans('ResourceSingular');
$head = resource_prepare_head($object);
@ -139,7 +147,9 @@ if ($object->id > 0)
$morehtmlref .= '</div>';
$shownav = 1;
if ($user->socid && !in_array('resource', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
if ($user->socid && !in_array('resource', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
$shownav = 0;
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@ -150,11 +160,14 @@ if ($object->id > 0)
print dol_get_fiche_end();
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
{
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$param = '&id='.$object->id.'&socid='.$socid;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
print_barre_liste($langs->trans("ActionsOnResource"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1);

View File

@ -44,13 +44,11 @@ $fk_code_type_resource = GETPOST('fk_code_type_resource', 'alpha');
$country_id = GETPOST('country_id', 'int');
// Protection if external user
if ($user->socid > 0)
{
if ($user->socid > 0) {
accessforbidden();
}
if (!$user->rights->resource->read)
{
if (!$user->rights->resource->read) {
accessforbidden();
}
@ -70,33 +68,28 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$hookmanager->initHooks(array('resource', 'resource_card', 'globalcard'));
$parameters = array('resource_id'=>$id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if ($cancel)
{
if (!empty($backtopage))
{
if (empty($reshook)) {
if ($cancel) {
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
if ($action == 'add')
{
if ($action == 'add') {
header("Location: ".DOL_URL_ROOT.'/resource/list.php');
exit;
}
$action = '';
}
if ($action == 'add' && $user->rights->resource->write)
{
if (!$cancel)
{
if ($action == 'add' && $user->rights->resource->write) {
if (!$cancel) {
$error = '';
if (empty($ref))
{
if (empty($ref)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
$action = 'create';
} else {
@ -107,11 +100,12 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if ($ret < 0) {
$error++;
}
$result = $object->create($user);
if ($result > 0)
{
if ($result > 0) {
// Creation OK
setEventMessages($langs->trans('ResourceCreatedWithSuccess'), null, 'mesgs');
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@ -128,21 +122,17 @@ if (empty($reshook))
}
}
if ($action == 'update' && !$cancel && $user->rights->resource->write)
{
if ($action == 'update' && !$cancel && $user->rights->resource->write) {
$error = 0;
if (empty($ref))
{
if (empty($ref)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
$error++;
}
if (!$error)
{
if (!$error) {
$res = $object->fetch($id);
if ($res > 0)
{
if ($res > 0) {
$object->ref = $ref;
$object->description = $description;
$object->fk_code_type_resource = $fk_code_type_resource;
@ -155,8 +145,7 @@ if (empty($reshook))
}
$result = $object->update($user);
if ($result > 0)
{
if ($result > 0) {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@ -169,21 +158,17 @@ if (empty($reshook))
}
}
if ($error)
{
if ($error) {
$action = 'edit';
}
}
if ($action == 'confirm_delete_resource' && $user->rights->resource->delete && $confirm === 'yes')
{
if ($action == 'confirm_delete_resource' && $user->rights->resource->delete && $confirm === 'yes') {
$res = $object->fetch($id);
if ($res > 0)
{
if ($res > 0) {
$result = $object->delete($id);
if ($result >= 0)
{
if ($result >= 0) {
setEventMessages($langs->trans('RessourceSuccessfullyDeleted'), null, 'mesgs');
Header('Location: '.DOL_URL_ROOT.'/resource/list.php');
exit;
@ -207,10 +192,8 @@ llxHeader('', $title, '');
$form = new Form($db);
$formresource = new FormResource($db);
if ($action == 'create' || $object->fetch($id, $ref) > 0)
{
if ($action == 'create')
{
if ($action == 'create' || $object->fetch($id, $ref) > 0) {
if ($action == 'create') {
print load_fiche_titre($title, '', 'object_resource');
print dol_get_fiche_head('');
} else {
@ -218,9 +201,10 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0)
print dol_get_fiche_head($head, 'resource', $title, -1, 'resource');
}
if ($action == 'create' || $action == 'edit')
{
if (!$user->rights->resource->write) accessforbidden('', 0, 1);
if ($action == 'create' || $action == 'edit') {
if (!$user->rights->resource->write) {
accessforbidden('', 0, 1);
}
// Create/Edit object
@ -251,15 +235,16 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0)
// Origin country
print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td>';
print $form->select_country($object->country_id, 'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td></tr>';
// Other attributes
$parameters = array('objectsrc' => $objectsrc);
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
if (empty($reshook)) {
print $object->showOptionals($extrafields, 'edit');
}
@ -279,8 +264,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0)
$formconfirm = '';
// Confirm deleting resource line
if ($action == 'delete')
{
if ($action == 'delete') {
$formconfirm = $form->formconfirm("card.php?&id=".$object->id, $langs->trans("DeleteResource"), $langs->trans("ConfirmDeleteResource"), "confirm_delete_resource", '', '', 1);
}
@ -352,23 +336,18 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0)
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
if (empty($reshook))
{
if ($action != "create" && $action != "edit")
{
if (empty($reshook)) {
if ($action != "create" && $action != "edit") {
// Edit resource
if ($user->rights->resource->write)
{
if ($user->rights->resource->write) {
print '<div class="inline-block divButAction">';
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$id.'&amp;action=edit" class="butAction">'.$langs->trans('Modify').'</a>';
print '</div>';
}
}
if ($action != "delete" && $action != "create" && $action != "edit")
{
if ($action != "delete" && $action != "create" && $action != "edit") {
// Delete resource
if ($user->rights->resource->delete)
{
if ($user->rights->resource->delete) {
print '<div class="inline-block divButAction">';
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$id.'&amp;action=delete&amp;token='.newToken().'" class="butActionDelete">'.$langs->trans('Delete').'</a>';
print '</div>';

View File

@ -87,12 +87,24 @@ class Dolresource extends CommonObject
// Clean parameters
if (isset($this->ref)) $this->ref = trim($this->ref);
if (isset($this->description)) $this->description = trim($this->description);
if (!is_numeric($this->country_id)) $this->country_id = 0;
if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource = trim($this->fk_code_type_resource);
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
if (isset($this->ref)) {
$this->ref = trim($this->ref);
}
if (isset($this->description)) {
$this->description = trim($this->description);
}
if (!is_numeric($this->country_id)) {
$this->country_id = 0;
}
if (isset($this->fk_code_type_resource)) {
$this->fk_code_type_resource = trim($this->fk_code_type_resource);
}
if (isset($this->note_public)) {
$this->note_public = trim($this->note_public);
}
if (isset($this->note_private)) {
$this->note_private = trim($this->note_private);
}
// Insert request
@ -122,39 +134,34 @@ class Dolresource extends CommonObject
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
}
if (!$error)
{
if (!$error) {
$action = 'create';
// Actions on extra fields
if (!$error)
{
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
}
}
if (!$error && !$notrigger)
{
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('RESOURCE_CREATE', $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
// End call triggers
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -189,15 +196,16 @@ class Dolresource extends CommonObject
$sql .= " ty.label as type_label";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
if ($id) $sql .= " WHERE t.rowid = ".$this->db->escape($id);
else $sql .= " WHERE t.ref = '".$this->db->escape($ref)."'";
if ($id) {
$sql .= " WHERE t.rowid = ".$this->db->escape($id);
} else {
$sql .= " WHERE t.ref = '".$this->db->escape($ref)."'";
}
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -238,13 +246,20 @@ class Dolresource extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->ref)) $this->ref = trim($this->ref);
if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource = trim($this->fk_code_type_resource);
if (isset($this->description)) $this->description = trim($this->description);
if (!is_numeric($this->country_id)) $this->country_id = 0;
if (isset($this->ref)) {
$this->ref = trim($this->ref);
}
if (isset($this->fk_code_type_resource)) {
$this->fk_code_type_resource = trim($this->fk_code_type_resource);
}
if (isset($this->description)) {
$this->description = trim($this->description);
}
if (!is_numeric($this->country_id)) {
$this->country_id = 0;
}
if (empty($this->oldcopy))
{
if (empty($this->oldcopy)) {
$org = new self($this->db);
$org->fetch($this->id);
$this->oldcopy = $org;
@ -263,31 +278,29 @@ class Dolresource extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$notrigger)
{
if (!$error) {
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('RESOURCE_MODIFY', $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
// End call triggers
}
}
if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref))
{
if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) {
// We remove directory
if (!empty($conf->resource->dir_output))
{
if (!empty($conf->resource->dir_output)) {
$olddir = $conf->resource->dir_output."/".dol_sanitizeFileName($this->oldcopy->ref);
$newdir = $conf->resource->dir_output."/".dol_sanitizeFileName($this->ref);
if (file_exists($olddir))
{
if (file_exists($olddir)) {
$res = @rename($olddir, $newdir);
if (!$res)
{
if (!$res) {
$langs->load("errors");
$this->error = $langs->trans('ErrorFailToRenameDir', $olddir, $newdir);
$error++;
@ -296,26 +309,21 @@ class Dolresource extends CommonObject
}
}
if (!$error)
{
if (!$error) {
$action = 'update';
// Actions on extra fields
if (!$error)
{
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0)
{
if ($result < 0) {
$error++;
}
}
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -340,7 +348,7 @@ class Dolresource extends CommonObject
global $langs;
$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.resource_id,";
$sql .= " t.resource_id,";
$sql .= " t.resource_type,";
$sql .= " t.element_id,";
$sql .= " t.element_type,";
@ -353,10 +361,8 @@ class Dolresource extends CommonObject
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -404,14 +410,12 @@ class Dolresource extends CommonObject
$sql .= " WHERE rowid =".$rowid;
dol_syslog(get_class($this), LOG_DEBUG);
if ($this->db->query($sql))
{
if ($this->db->query($sql)) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
$sql .= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$this->error = $this->db->lasterror();
$error++;
}
@ -423,33 +427,29 @@ class Dolresource extends CommonObject
// Removed extrafields
if (!$error) {
$result = $this->deleteExtraFields();
if ($result < 0)
{
if ($result < 0) {
$error++;
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
}
}
if (!$notrigger)
{
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('RESOURCE_DELETE', $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
// End call triggers
}
if (!$error)
{
if (!$error) {
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if (!empty($conf->resource->dir_output))
{
if (!empty($conf->resource->dir_output)) {
$dir = $conf->resource->dir_output."/".dol_sanitizeFileName($this->ref);
if (file_exists($dir))
{
if (file_exists($dir)) {
$res = @dol_delete_dir_recursive($dir);
if (!$res)
{
if (!$res) {
$this->errors[] = 'ErrorFailToDeleteDir';
$error++;
}
@ -457,8 +457,7 @@ class Dolresource extends CommonObject
}
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -494,8 +493,11 @@ class Dolresource extends CommonObject
$sql .= " t.fk_code_type_resource,";
$sql .= " t.tms,";
// Add fields from extrafields
if (!empty($extrafields->attributes[$this->table_element]['label']))
foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
if (!empty($extrafields->attributes[$this->table_element]['label'])) {
foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
}
}
$sql .= " ty.label as type_label";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
@ -515,23 +517,21 @@ class Dolresource extends CommonObject
}
$sql .= $this->db->order($sortfield, $sortorder);
$this->num_all = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $this->db->query($sql);
$this->num_all = $this->db->num_rows($result);
}
if ($limit) $sql .= $this->db->plimit($limit, $offset);
if ($limit) {
$sql .= $this->db->plimit($limit, $offset);
}
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
$this->lines = array();
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num)
{
while ($obj = $this->db->fetch_object($resql))
{
if ($num) {
while ($obj = $this->db->fetch_object($resql)) {
$line = new Dolresource($this->db);
$line->id = $obj->rowid;
$line->ref = $obj->ref;
@ -569,10 +569,10 @@ class Dolresource extends CommonObject
public function fetch_all_resources($sortorder, $sortfield, $limit, $offset, $filter = '')
{
// phpcs:enable
global $conf;
$sql = "SELECT ";
$sql .= " t.rowid,";
$sql .= " t.resource_id,";
global $conf;
$sql = "SELECT ";
$sql .= " t.rowid,";
$sql .= " t.resource_id,";
$sql .= " t.resource_type,";
$sql .= " t.element_id,";
$sql .= " t.element_type,";
@ -580,54 +580,55 @@ class Dolresource extends CommonObject
$sql .= " t.mandatory,";
$sql .= " t.fk_user_create,";
$sql .= " t.tms";
$sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources as t ';
$sql .= " WHERE t.entity IN (".getEntity('resource').")";
$sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources as t ';
$sql .= " WHERE t.entity IN (".getEntity('resource').")";
//Manage filter
if (!empty($filter)) {
foreach ($filter as $key => $value) {
if (strpos($key, 'date')) {
$sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\'';
} else {
$sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\'';
}
}
}
//Manage filter
if (!empty($filter)) {
foreach ($filter as $key => $value) {
if (strpos($key, 'date')) {
$sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\'';
} else {
$sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\'';
}
}
}
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) $sql .= $this->db->plimit($limit + 1, $offset);
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
if ($limit) {
$sql .= $this->db->plimit($limit + 1, $offset);
}
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
if ($num)
{
while ($obj = $this->db->fetch_object($resql))
{
$line = new Dolresource($this->db);
$line->id = $obj->rowid;
$line->resource_id = $obj->resource_id;
$line->resource_type = $obj->resource_type;
$line->element_id = $obj->element_id;
$line->element_type = $obj->element_type;
$line->busy = $obj->busy;
$line->mandatory = $obj->mandatory;
$line->fk_user_create = $obj->fk_user_create;
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num) {
while ($obj = $this->db->fetch_object($resql)) {
$line = new Dolresource($this->db);
$line->id = $obj->rowid;
$line->resource_id = $obj->resource_id;
$line->resource_type = $obj->resource_type;
$line->element_id = $obj->element_id;
$line->element_type = $obj->element_type;
$line->busy = $obj->busy;
$line->mandatory = $obj->mandatory;
$line->fk_user_create = $obj->fk_user_create;
if ($obj->resource_id && $obj->resource_type)
if ($obj->resource_id && $obj->resource_type) {
$line->objresource = fetchObjectByElement($obj->resource_id, $obj->resource_type);
if ($obj->element_id && $obj->element_type)
}
if ($obj->element_id && $obj->element_type) {
$line->objelement = fetchObjectByElement($obj->element_id, $obj->element_type);
}
$this->lines[] = $line;
}
$this->db->free($resql);
}
return $num;
} else {
$this->error = $this->db->lasterror();
return -1;
}
}
$this->db->free($resql);
}
return $num;
} else {
$this->error = $this->db->lasterror();
return -1;
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@ -646,8 +647,12 @@ class Dolresource extends CommonObject
// phpcs:enable
global $conf;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "t.rowid";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "t.rowid";
}
$sql = "SELECT ";
$sql .= " t.rowid,";
@ -673,18 +678,17 @@ class Dolresource extends CommonObject
}
}
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) $sql .= $this->db->plimit($limit + 1, $offset);
if ($limit) {
$sql .= $this->db->plimit($limit + 1, $offset);
}
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num)
{
if ($num) {
$this->lines = array();
while ($obj = $this->db->fetch_object($resql))
{
while ($obj = $this->db->fetch_object($resql)) {
$line = new Dolresource($this->db);
$line->id = $obj->rowid;
$line->resource_id = $obj->resource_id;
@ -720,8 +724,7 @@ class Dolresource extends CommonObject
// phpcs:enable
global $conf;
if (!empty($conf->modules_parts['resources']))
{
if (!empty($conf->modules_parts['resources'])) {
$this->available_resources = (array) $conf->modules_parts['resources'];
return count($this->available_resources);
@ -744,12 +747,24 @@ class Dolresource extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->resource_id)) $this->resource_id = trim($this->resource_id);
if (isset($this->resource_type)) $this->resource_type = trim($this->resource_type);
if (isset($this->element_id)) $this->element_id = trim($this->element_id);
if (isset($this->element_type)) $this->element_type = trim($this->element_type);
if (isset($this->busy)) $this->busy = trim($this->busy);
if (isset($this->mandatory)) $this->mandatory = trim($this->mandatory);
if (isset($this->resource_id)) {
$this->resource_id = trim($this->resource_id);
}
if (isset($this->resource_type)) {
$this->resource_type = trim($this->resource_type);
}
if (isset($this->element_id)) {
$this->element_id = trim($this->element_id);
}
if (isset($this->element_type)) {
$this->element_type = trim($this->element_type);
}
if (isset($this->busy)) {
$this->busy = trim($this->busy);
}
if (isset($this->mandatory)) {
$this->mandatory = trim($this->mandatory);
}
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."element_resources SET";
@ -767,24 +782,24 @@ class Dolresource extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$notrigger)
{
if (!$error) {
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('RESOURCE_MODIFY', $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -813,20 +828,19 @@ class Dolresource extends CommonObject
$sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory';
$sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources';
$sql .= " WHERE element_id=".$element_id." AND element_type='".$this->db->escape($element)."'";
if ($resource_type)
if ($resource_type) {
$sql .= " AND resource_type LIKE '%".$this->db->escape($resource_type)."%'";
}
$sql .= ' ORDER BY resource_type';
dol_syslog(get_class($this)."::getElementResources", LOG_DEBUG);
$resources = array();
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
$resources[$i] = array(
@ -873,7 +887,9 @@ class Dolresource extends CommonObject
// phpcs:enable
global $langs;
if (is_array($this->cache_code_type_resource) && count($this->cache_code_type_resource)) return 0; // Cache deja charge
if (is_array($this->cache_code_type_resource) && count($this->cache_code_type_resource)) {
return 0; // Cache deja charge
}
$sql = "SELECT rowid, code, label, active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_resource";
@ -881,12 +897,10 @@ class Dolresource extends CommonObject
$sql .= " ORDER BY rowid";
dol_syslog(get_class($this)."::load_cache_code_type_resource", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$label = ($langs->trans("ResourceTypeShort".$obj->code) != ("ResourceTypeShort".$obj->code) ? $langs->trans("ResourceTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
@ -922,43 +936,50 @@ class Dolresource extends CommonObject
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
/*if (isset($this->status)) {
$label.= '<br><b>' . $langs->trans("Status").":</b> ".$this->getLibStatut(5);
}*/
$label.= '<br><b>' . $langs->trans("Status").":</b> ".$this->getLibStatut(5);
}*/
if (isset($this->type_label)) {
$label .= '<br><b>'.$langs->trans("ResourceType").":</b> ".$this->type_label;
}
$url = DOL_URL_ROOT.'/resource/card.php?id='.$this->id;
if ($option != 'nolink')
{
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
}
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowMyObject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.$get_params.'"';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
/*$linkstart = '<a href="'.dol_buildpath('/resource/card.php', 1).'?id='.$this->id.$get_params.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend = '</a>';*/
$linkend = '</a>';*/
$result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= $this->ref;
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend;
return $result;

View File

@ -90,18 +90,17 @@ class FormResource
$resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, 0, $filter);
if (!is_array($selected)) $selected = array($selected);
if (!is_array($selected)) {
$selected = array($selected);
}
if ($outputmode != 2)
{
if ($outputmode != 2) {
$out = '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$out .= '<input type="hidden" name="token" value="'.newToken().'">';
}
if ($resourcestat)
{
if (!empty($conf->use_javascript_ajax) && !empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && !$forcecombo)
{
if ($resourcestat) {
if (!empty($conf->use_javascript_ajax) && !empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && !$forcecombo) {
//$minLength = (is_numeric($conf->global->RESOURCE_USE_SEARCH_TO_SELECT)?$conf->global->RESOURCE_USE_SEARCH_TO_SELECT:2);
$out .= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT);
} else {
@ -110,24 +109,27 @@ class FormResource
// Construct $out and $outarray
$out .= '<select id="'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').'>'."\n";
if ($showempty) $out .= '<option value="-1">&nbsp;</option>'."\n";
if ($showempty) {
$out .= '<option value="-1">&nbsp;</option>'."\n";
}
$num = 0;
if (is_array($resourcestat->lines)) $num = count($resourcestat->lines);
if (is_array($resourcestat->lines)) {
$num = count($resourcestat->lines);
}
//var_dump($resourcestat->lines);
$i = 0;
if ($num)
{
while ($i < $num)
{
if ($num) {
while ($i < $num) {
$resourceclass = ucfirst($resourcestat->lines[$i]->element);
$label = $resourcestat->lines[$i]->ref ? $resourcestat->lines[$i]->ref : ''.$resourcestat->lines[$i]->label;
if ($resourceclass != 'Dolresource') $label .= ' ('.$langs->trans($resourceclass).')';
if ($resourceclass != 'Dolresource') {
$label .= ' ('.$langs->trans($resourceclass).')';
}
if ((is_object($selected[0]) && $selected[0]->id == $resourcestat->lines[$i]->id) || (!is_object($selected[0]) && in_array($resourcestat->lines[$i]->id, $selected)))
{
if ((is_object($selected[0]) && $selected[0]->id == $resourcestat->lines[$i]->id) || (!is_object($selected[0]) && in_array($resourcestat->lines[$i]->id, $selected))) {
$out .= '<option value="'.$resourcestat->lines[$i]->id.'" selected>'.$label.'</option>';
} else {
$out .= '<option value="'.$resourcestat->lines[$i]->id.'">'.$label.'</option>';
@ -136,13 +138,14 @@ class FormResource
array_push($outarray, array('key'=>$resourcestat->lines[$i]->id, 'value'=>$resourcestat->lines[$i]->label, 'label'=>$resourcestat->lines[$i]->label));
$i++;
if (($i % 10) == 0) $out .= "\n";
if (($i % 10) == 0) {
$out .= "\n";
}
}
}
$out .= '</select>'."\n";
if ($outputmode != 2)
{
if ($outputmode != 2) {
$out .= '<input type="submit" class="button" value="'.$langs->trans("Search").'"> &nbsp; &nbsp; ';
$out .= '</form>';
@ -151,7 +154,9 @@ class FormResource
dol_print_error($this->db);
}
if ($outputmode && $outputmode != 2) return $outarray;
if ($outputmode && $outputmode != 2) {
return $outarray;
}
return $out;
}
@ -179,35 +184,54 @@ class FormResource
$filterarray = array();
if ($filtertype != '' && $filtertype != '-1') $filterarray = explode(',', $filtertype);
if ($filtertype != '' && $filtertype != '-1') {
$filterarray = explode(',', $filtertype);
}
$resourcestat->load_cache_code_type_resource();
print '<select id="select'.$htmlname.'" class="flat maxwidthonsmartphone select_'.$htmlname.'" name="'.$htmlname.'">';
if ($empty) print '<option value="">&nbsp;</option>';
if (is_array($resourcestat->cache_code_type_resource) && count($resourcestat->cache_code_type_resource))
{
foreach ($resourcestat->cache_code_type_resource as $id => $arraytypes)
{
if ($empty) {
print '<option value="">&nbsp;</option>';
}
if (is_array($resourcestat->cache_code_type_resource) && count($resourcestat->cache_code_type_resource)) {
foreach ($resourcestat->cache_code_type_resource as $id => $arraytypes) {
// We discard empty line if showempty is on because an empty line has already been output.
if ($empty && empty($arraytypes['code'])) continue;
if ($empty && empty($arraytypes['code'])) {
continue;
}
if ($format == 0) print '<option value="'.$id.'"';
elseif ($format == 1) print '<option value="'.$arraytypes['code'].'"';
elseif ($format == 2) print '<option value="'.$arraytypes['code'].'"';
elseif ($format == 3) print '<option value="'.$id.'"';
if ($format == 0) {
print '<option value="'.$id.'"';
} elseif ($format == 1) {
print '<option value="'.$arraytypes['code'].'"';
} elseif ($format == 2) {
print '<option value="'.$arraytypes['code'].'"';
} elseif ($format == 3) {
print '<option value="'.$id.'"';
}
// Si selected est text, on compare avec code, sinon avec id
if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code']) print ' selected';
elseif ($selected == $id) print ' selected';
if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code']) {
print ' selected';
} elseif ($selected == $id) {
print ' selected';
}
print '>';
if ($format == 0) $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
elseif ($format == 1) $value = $arraytypes['code'];
elseif ($format == 2) $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
elseif ($format == 3) $value = $arraytypes['code'];
if ($format == 0) {
$value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
} elseif ($format == 1) {
$value = $arraytypes['code'];
} elseif ($format == 2) {
$value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
} elseif ($format == 3) {
$value = $arraytypes['code'];
}
print $value ? $value : '&nbsp;';
print '</option>';
}
}
print '</select>';
if ($user->admin && !$noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
}
}

View File

@ -39,7 +39,9 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'resource', $id, 'resource');
$object = new DolResource($db);
@ -50,17 +52,14 @@ $result = $object->fetch($id, $ref);
* Add a new contact
*/
if ($action == 'addcontact' && $user->rights->resource->write)
{
if ($result > 0 && $id > 0)
{
if ($action == 'addcontact' && $user->rights->resource->write) {
if ($result > 0 && $id > 0) {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
}
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@ -73,21 +72,14 @@ if ($action == 'addcontact' && $user->rights->resource->write)
setEventMessages($mesg, null, 'errors');
}
}
// Toggle the status of a contact
elseif ($action == 'swapstatut' && $user->rights->resource->write)
{
} elseif ($action == 'swapstatut' && $user->rights->resource->write) {
// Toggle the status of a contact
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
}
// Erase a contact
elseif ($action == 'deletecontact' && $user->rights->resource->write)
{
} elseif ($action == 'deletecontact' && $user->rights->resource->write) {
// Erase a contact
$result = $object->delete_contact(GETPOST('lineid', 'int'));
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@ -109,8 +101,7 @@ llxHeader('', $langs->trans("Resource"));
// Mode vue et edition
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$soc = new Societe($db);
$soc->fetch($object->socid);
@ -152,8 +143,12 @@ if ($id > 0 || !empty($ref))
print '<br>';
if (!empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser = 1;
if (!empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty = 1;
if (!empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER)) {
$hideaddcontactforuser = 1;
}
if (!empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY)) {
$hideaddcontactforthirdparty = 1;
}
$permission = 1;
// Contacts lines

View File

@ -44,7 +44,9 @@ $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'resource', $id, 'resource');
@ -53,12 +55,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$object = new DolResource($db);
@ -83,8 +91,7 @@ $form = new Form($db);
llxHeader('', $langs->trans("Resource"));
if ($object->id > 0)
{
if ($object->id > 0) {
$object->fetch_thirdparty();
$head = resource_prepare_head($object);
@ -95,8 +102,7 @@ if ($object->id > 0)
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
foreach ($filearray as $key => $file)
{
foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}

View File

@ -45,8 +45,9 @@ $sortfield = GETPOST('sortfield','alpha');
$page = GETPOST('page','int');
*/
if (!$user->rights->resource->read)
if (!$user->rights->resource->read) {
accessforbidden();
}
$object = new Dolresource($db);
@ -69,8 +70,7 @@ $cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$socid = GETPOST('socid', 'int');
if ($socid > 0) // Special for thirdparty
{
if ($socid > 0) { // Special for thirdparty
$element_id = $socid;
$element = 'societe';
}
@ -83,17 +83,16 @@ if ($socid > 0) // Special for thirdparty
$parameters = array('resource_id' => $resource_id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
$error = 0;
if ($action == 'add_element_resource' && !$cancel)
{
if ($action == 'add_element_resource' && !$cancel) {
$res = 0;
if (!($resource_id > 0))
{
if (!($resource_id > 0)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Resource")), null, 'errors');
$action = '';
@ -162,23 +161,19 @@ if (empty($reshook))
}
}
if (!$error && $res > 0)
{
if (!$error && $res > 0) {
setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$objstat->id);
exit;
} elseif ($objstat)
{
} elseif ($objstat) {
setEventMessages($objstat->error, $objstat->errors, 'errors');
}
}
// Update ressource
if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel', 'alpha'))
{
if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel', 'alpha')) {
$res = $object->fetch_element_resource($lineid);
if ($res)
{
if ($res) {
$object->busy = $busy;
$object->mandatory = $mandatory;
@ -239,7 +234,9 @@ if (empty($reshook))
if (!$error) {
$result = $object->update_element_resource($user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
}
if ($error) {
@ -253,12 +250,10 @@ if (empty($reshook))
}
// Delete a resource linked to an element
if ($action == 'confirm_delete_linked_resource' && $user->rights->resource->delete && $confirm === 'yes')
{
if ($action == 'confirm_delete_linked_resource' && $user->rights->resource->delete && $confirm === 'yes') {
$result = $object->delete_resource($lineid, $element);
if ($result >= 0)
{
if ($result >= 0) {
setEventMessages($langs->trans('RessourceLineSuccessfullyDeleted'), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id);
exit;
@ -270,7 +265,9 @@ if (empty($reshook))
$parameters = array('resource_id'=>$resource_id);
$reshook = $hookmanager->executeHooks('getElementResources', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
@ -294,20 +291,17 @@ if (!$ret) {
print '<div class="warning">'.$langs->trans('NoResourceInDatabase').'</div>';
} else {
// Confirmation suppression resource line
if ($action == 'delete_resource')
{
if ($action == 'delete_resource') {
print $form->formconfirm("element_resource.php?element=".$element."&element_id=".$element_id."&id=".$id."&lineid=".$lineid, $langs->trans("DeleteResource"), $langs->trans("ConfirmDeleteResourceElement"), "confirm_delete_linked_resource", '', '', 1);
}
// Specific to agenda module
if (($element_id || $element_ref) && $element == 'action')
{
if (($element_id || $element_ref) && $element == 'action') {
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
$act = fetchObjectByElement($element_id, $element, $element_ref);
if (is_object($act))
{
if (is_object($act)) {
$head = actions_prepare_head($act);
print dol_get_fiche_head($head, 'resources', $langs->trans("Action"), -1, 'action');
@ -332,8 +326,7 @@ if (!$ret) {
// Thirdparty
//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
//$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
$morehtmlref .= $langs->trans('Project').': ';
@ -343,7 +336,9 @@ if (!$ret) {
$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$act->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref .= $proj->ref;
$morehtmlref .= '</a>';
if ($proj->title) $morehtmlref .= ' - '.$proj->title;
if ($proj->title) {
$morehtmlref .= ' - '.$proj->title;
}
} else {
$morehtmlref .= '';
}
@ -359,8 +354,7 @@ if (!$ret) {
print '<table class="border tableforfield" width="100%">';
// Type
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$act->type.'</td></tr>';
}
@ -369,44 +363,53 @@ if (!$ret) {
// Date start
print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">';
if (!$act->fulldayevent) print dol_print_date($act->datep, 'dayhour');
else print dol_print_date($act->datep, 'day');
if ($act->percentage == 0 && $act->datep && $act->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late"));
if (!$act->fulldayevent) {
print dol_print_date($act->datep, 'dayhour');
} else {
print dol_print_date($act->datep, 'day');
}
if ($act->percentage == 0 && $act->datep && $act->datep < ($now - $delay_warning)) {
print img_warning($langs->trans("Late"));
}
print '</td>';
print '</tr>';
// Date end
print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">';
if (!$act->fulldayevent) print dol_print_date($act->datef, 'dayhour');
else print dol_print_date($act->datef, 'day');
if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late"));
if (!$act->fulldayevent) {
print dol_print_date($act->datef, 'dayhour');
} else {
print dol_print_date($act->datef, 'day');
}
if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now - $delay_warning)) {
print img_warning($langs->trans("Late"));
}
print '</td></tr>';
// Location
if (empty($conf->global->AGENDA_DISABLE_LOCATION))
{
if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3">'.$act->location.'</td></tr>';
}
// Assigned to
print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
$listofuserid = array();
if (empty($donotclearsession))
{
if ($act->userownerid > 0) $listofuserid[$act->userownerid] = array('id'=>$act->userownerid, 'transparency'=>$act->transparency); // Owner first
if (!empty($act->userassigned)) // Now concat assigned users
{
if (empty($donotclearsession)) {
if ($act->userownerid > 0) {
$listofuserid[$act->userownerid] = array('id'=>$act->userownerid, 'transparency'=>$act->transparency); // Owner first
}
if (!empty($act->userassigned)) { // Now concat assigned users
// Restore array with key with same value than param 'id'
$tmplist1 = $act->userassigned; $tmplist2 = array();
foreach ($tmplist1 as $key => $val)
{
if ($val['id'] && $val['id'] != $act->userownerid) $listofuserid[$val['id']] = $val;
foreach ($tmplist1 as $key => $val) {
if ($val['id'] && $val['id'] != $act->userownerid) {
$listofuserid[$val['id']] = $val;
}
}
}
$_SESSION['assignedtouser'] = json_encode($listofuserid);
} else {
if (!empty($_SESSION['assignedtouser']))
{
if (!empty($_SESSION['assignedtouser'])) {
$listofuserid = json_decode($_SESSION['assignedtouser'], true);
}
}
@ -432,8 +435,7 @@ if (!$ret) {
}
// Specific to thirdparty module
if (($element_id || $element_ref) && $element == 'societe')
{
if (($element_id || $element_ref) && $element == 'societe') {
$socstatic = fetchObjectByElement($element_id, $element, $element_ref);
if (is_object($socstatic)) {
$savobject = $object;
@ -467,16 +469,14 @@ if (!$ret) {
}
// Specific to fichinter module
if (($element_id || $element_ref) && $element == 'fichinter')
{
if (($element_id || $element_ref) && $element == 'fichinter') {
require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
$fichinter = new Fichinter($db);
$fichinter->fetch($element_id, $element_ref);
$fichinter->fetch_thirdparty();
if (is_object($fichinter))
{
if (is_object($fichinter)) {
$head = fichinter_prepare_head($fichinter);
print dol_get_fiche_head($head, 'resource', $langs->trans("InterventionCard"), -1, 'intervention');
@ -491,15 +491,14 @@ if (!$ret) {
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$fichinter->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
if ($user->rights->commande->creer) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $fichinter->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';
}
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $fichinter->id, $fichinter->socid, $fichinter->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$fichinter->id.'">';
@ -532,15 +531,13 @@ if (!$ret) {
}
// Specific to product/service module
if (($element_id || $element_ref) && ($element == 'product' || $element == 'service'))
{
if (($element_id || $element_ref) && ($element == 'product' || $element == 'service')) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
$product = new Product($db);
$product->fetch($element_id, $element_ref);
if (is_object($product))
{
if (is_object($product)) {
$head = product_prepare_head($product);
$titre = $langs->trans("CardProduct".$product->type);
$picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product');
@ -548,7 +545,9 @@ if (!$ret) {
print dol_get_fiche_head($head, 'resources', $titre, -1, $picto);
$shownav = 1;
if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
$shownav = 0;
}
dol_banner_tab($product, 'ref', '', $shownav, 'ref', 'ref', '', '&element='.$element);
print dol_get_fiche_end();
@ -559,7 +558,9 @@ if (!$ret) {
// hook for other elements linked
$parameters = array('element'=>$element, 'element_id'=>$element_id, 'element_ref'=>$element_ref);
$reshook = $hookmanager->executeHooks('printElementTab', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
//print load_fiche_titre($langs->trans('ResourcesLinkedToElement'),'','');
@ -567,18 +568,17 @@ if (!$ret) {
// Show list of resource links
foreach ($object->available_resources as $modresources => $resources)
{
foreach ($object->available_resources as $modresources => $resources) {
$resources = (array) $resources; // To be sure $resources is an array
foreach ($resources as $resource_obj)
{
foreach ($resources as $resource_obj) {
$element_prop = getElementProperties($resource_obj);
//print '/'.$modresources.'/class/'.$resource_obj.'.class.php<br>';
$path = '';
if (strpos($resource_obj, '@'))
if (strpos($resource_obj, '@')) {
$path .= '/'.$element_prop['module'];
}
$linked_resources = $object->getElementResources($element, $element_id, $resource_obj);
@ -586,10 +586,8 @@ if (!$ret) {
$defaulttpldir = '/core/tpl';
$dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir), array($path.$defaulttpldir));
foreach ($dirtpls as $module => $reldir)
{
if (file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php')))
{
foreach ($dirtpls as $module => $reldir) {
if (file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php'))) {
$tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php');
} else {
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_add.tpl.php';
@ -599,15 +597,14 @@ if (!$ret) {
} else {
$res = include $tpl; // for debug
}
if ($res) break;
if ($res) {
break;
}
}
if ($mode != 'add' || $resource_obj != $resource_type)
{
foreach ($dirtpls as $module => $reldir)
{
if (file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php')))
{
if ($mode != 'add' || $resource_obj != $resource_type) {
foreach ($dirtpls as $module => $reldir) {
if (file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php'))) {
$tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php');
} else {
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_view.tpl.php';
@ -617,7 +614,9 @@ if (!$ret) {
} else {
$res = include $tpl; // for debug
}
if ($res) break;
if ($res) {
break;
}
}
}
}

View File

@ -51,7 +51,9 @@ $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
if (!is_array($search_array_options)) $search_array_options = array();
if (!is_array($search_array_options)) {
$search_array_options = array();
}
$search_ref = GETPOST("search_ref", 'alpha');
$search_type = GETPOST("search_type", 'alpha');
@ -62,8 +64,12 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$filter = array();
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&amp;contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&amp;limit='.urlencode($limit);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&amp;contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&amp;limit='.urlencode($limit);
}
if ($search_ref != '') {
$param .= '&search_ref='.urlencode($search_ref);
@ -75,8 +81,7 @@ if ($search_type != '') {
}
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
foreach ($search_array_options as $key => $val) {
$crit = $val;
$tmpkey = preg_replace('/search_options_/', '', $key);
$typ = $extrafields->attributes[$object->table_element]['type'][$tmpkey];
@ -84,25 +89,38 @@ foreach ($search_array_options as $key => $val)
$param .= '&search_options_'.$tmpkey.'='.urlencode($val);
}
$mode_search = 0;
if (in_array($typ, array('int', 'double', 'real'))) $mode_search = 1; // Search on a numeric
if (in_array($typ, array('sellist', 'link')) && $crit != '0' && $crit != '-1') $mode_search = 2; // Search on a foreign key int
if ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1'))
{
if (in_array($typ, array('int', 'double', 'real'))) {
$mode_search = 1; // Search on a numeric
}
if (in_array($typ, array('sellist', 'link')) && $crit != '0' && $crit != '-1') {
$mode_search = 2; // Search on a foreign key int
}
if ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1')) {
$filter['ef.'.$tmpkey] = natural_search('ef.'.$tmpkey, $crit, $mode_search);
}
}
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
$hookmanager->initHooks(array('resourcelist'));
if (empty($sortorder)) $sortorder = "ASC";
if (empty($sortfield)) $sortfield = "t.ref";
if (empty($arch)) $arch = 0;
if (empty($sortorder)) {
$sortorder = "ASC";
}
if (empty($sortfield)) {
$sortfield = "t.ref";
}
if (empty($arch)) {
$arch = 0;
}
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -130,8 +148,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Do we click on purge search criteria ?
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
$search_ref = "";
$search_type = "";
$search_array_options = array();
@ -145,7 +162,9 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
/*
@ -158,8 +177,7 @@ $pagetitle = $langs->trans('ResourcePageIndex');
llxHeader('', $pagetitle, '');
// Confirmation suppression resource line
if ($action == 'delete_resource')
{
if ($action == 'delete_resource') {
print $form->formconfirm($_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id."&lineid=".$lineid, $langs->trans("DeleteResource"), $langs->trans("ConfirmDeleteResourceElement"), "confirm_delete_resource", '', '', 1);
}
@ -167,7 +185,9 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -175,8 +195,7 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$ret = $object->fetch_all('', '', 0, 0, $filter);
if ($ret == -1) {
dol_print_error($db, $object->error);
@ -193,8 +212,7 @@ if ($ret == -1) {
exit;
} else {
$newcardbutton = '';
if ($user->rights->resource->write)
{
if ($user->rights->resource->write) {
$newcardbutton .= dolGetButtonTitle($langs->trans('MenuResourceAdd'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/resource/card.php?action=create');
}
@ -207,14 +225,12 @@ print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['t.ref']['checked']))
{
if (!empty($arrayfields['t.ref']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="6">';
print '</td>';
}
if (!empty($arrayfields['ty.label']['checked']))
{
if (!empty($arrayfields['ty.label']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_type" value="'.$search_type.'" size="6">';
print '</td>';
@ -229,34 +245,38 @@ print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
if (!empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['ty.label']['checked'])) print_liste_field_titre($arrayfields['ty.label']['label'], $_SERVER["PHP_SELF"], "ty.label", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['t.ref']['checked'])) {
print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['ty.label']['checked'])) {
print_liste_field_titre($arrayfields['ty.label']['label'], $_SERVER["PHP_SELF"], "ty.label", "", $param, "", $sortfield, $sortorder);
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
if ($ret)
{
foreach ($object->lines as $resource)
{
if ($ret) {
foreach ($object->lines as $resource) {
print '<tr class="oddeven">';
if (!empty($arrayfields['t.ref']['checked']))
{
if (!empty($arrayfields['t.ref']['checked'])) {
print '<td>';
print $resource->getNomUrl(5);
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['ty.label']['checked']))
{
if (!empty($arrayfields['ty.label']['checked'])) {
print '<td>';
print $resource->type_label;
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Extra fields
$obj = (Object) $resource->array_options;
@ -271,13 +291,19 @@ if ($ret)
print img_delete('', 'class="marginleftonly"');
print '</a>';
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>';
}
} else {
$colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}

View File

@ -37,7 +37,9 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'resource', $id, 'resource');
$object = new DolResource($db);
@ -61,8 +63,7 @@ llxHeader();
$form = new Form($db);
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$head = resource_prepare_head($object);
print dol_get_fiche_head($head, 'note', $langs->trans('ResourceSingular'), -1, 'resource');