Merge remote-tracking branch 'upstream/develop' into 14a22
This commit is contained in:
commit
e35379a95d
@ -642,7 +642,7 @@ function dol_get_first_day_week($day, $month, $year, $gm = false)
|
||||
*/
|
||||
function getGMTEasterDatetime($year)
|
||||
{
|
||||
$base = new DateTime("$year-03-21");
|
||||
$base = new DateTime("$year-03-21", new DateTimeZone("UTC"));
|
||||
$days = easter_days($year); // Return number of days between 21 march and easter day.
|
||||
$tmp = $base->add(new DateInterval("P{$days}D"));
|
||||
return $tmp->getTimestamp();
|
||||
@ -650,11 +650,11 @@ function getGMTEasterDatetime($year)
|
||||
|
||||
/**
|
||||
* Return the number of non working days including saturday and sunday (or not) between 2 dates in timestamp.
|
||||
* Dates must be UTC with hour, day, min to 0.
|
||||
* Dates must be UTC with hour, min, sec to 0.
|
||||
* Called by function num_open_day()
|
||||
*
|
||||
* @param int $timestampStart Timestamp de debut
|
||||
* @param int $timestampEnd Timestamp de fin
|
||||
* @param int $timestampStart Timestamp start (UTC with hour, min, sec = 0)
|
||||
* @param int $timestampEnd Timestamp end (UTC with hour, min, sec = 0)
|
||||
* @param string $country_code Country code
|
||||
* @param int $lastday Last day is included, 0: no, 1:yes
|
||||
* @param int $includesaturday Include saturday as non working day (-1=use setup, 0=no, 1=yes)
|
||||
@ -755,33 +755,21 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '',
|
||||
if (in_array('eastermonday', $specialdayrule)) {
|
||||
// Calculation for the monday of easter date
|
||||
$date_paques = getGMTEasterDatetime($annee);
|
||||
$date_lundi_paques = mktime(
|
||||
gmdate("H", $date_paques),
|
||||
gmdate("i", $date_paques),
|
||||
gmdate("s", $date_paques),
|
||||
gmdate("m", $date_paques),
|
||||
gmdate("d", $date_paques) + 1,
|
||||
gmdate("Y", $date_paques)
|
||||
);
|
||||
//print 'PPP'.$date_paques.' '.dol_print_date($date_paques, 'dayhour', 'gmt')." ";
|
||||
$date_lundi_paques = $date_paques + (3600 * 24);
|
||||
$jour_lundi_paques = gmdate("d", $date_lundi_paques);
|
||||
$mois_lundi_paques = gmdate("m", $date_lundi_paques);
|
||||
if ($jour_lundi_paques == $jour && $mois_lundi_paques == $mois) {
|
||||
$ferie = true;
|
||||
}
|
||||
// Easter (monday)
|
||||
//print 'annee='.$annee.' $jour='.$jour.' $mois='.$mois.' $jour_lundi_paques='.$jour_lundi_paques.' $mois_lundi_paques='.$mois_lundi_paques."\n";
|
||||
}
|
||||
|
||||
if (in_array('ascension', $specialdayrule)) {
|
||||
// Calcul du jour de l'ascension (39 days after easter day)
|
||||
$date_paques = getGMTEasterDatetime($annee);
|
||||
$date_ascension = mktime(
|
||||
gmdate("H", $date_paques),
|
||||
gmdate("i", $date_paques),
|
||||
gmdate("s", $date_paques),
|
||||
gmdate("m", $date_paques),
|
||||
gmdate("d", $date_paques) + 39,
|
||||
gmdate("Y", $date_paques)
|
||||
);
|
||||
$date_ascension = $date_paques + (3600 * 24 * 39);
|
||||
$jour_ascension = gmdate("d", $date_ascension);
|
||||
$mois_ascension = gmdate("m", $date_ascension);
|
||||
if ($jour_ascension == $jour && $mois_ascension == $mois) {
|
||||
@ -793,14 +781,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '',
|
||||
if (in_array('pentecote', $specialdayrule)) {
|
||||
// Calculation of "Pentecote" (49 days after easter day)
|
||||
$date_paques = getGMTEasterDatetime($annee);
|
||||
$date_pentecote = mktime(
|
||||
gmdate("H", $date_paques),
|
||||
gmdate("i", $date_paques),
|
||||
gmdate("s", $date_paques),
|
||||
gmdate("m", $date_paques),
|
||||
gmdate("d", $date_paques) + 49,
|
||||
gmdate("Y", $date_paques)
|
||||
);
|
||||
$date_pentecote = $date_paques + (3600 * 24 * 49);
|
||||
$jour_pentecote = gmdate("d", $date_pentecote);
|
||||
$mois_pentecote = gmdate("m", $date_pentecote);
|
||||
if ($jour_pentecote == $jour && $mois_pentecote == $mois) {
|
||||
@ -811,14 +792,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '',
|
||||
if (in_array('pentecotemonday', $specialdayrule)) {
|
||||
// Calculation of "Pentecote" (49 days after easter day)
|
||||
$date_paques = getGMTEasterDatetime($annee);
|
||||
$date_pentecote = mktime(
|
||||
gmdate("H", $date_paques),
|
||||
gmdate("i", $date_paques),
|
||||
gmdate("s", $date_paques),
|
||||
gmdate("m", $date_paques),
|
||||
gmdate("d", $date_paques) + 50,
|
||||
gmdate("Y", $date_paques)
|
||||
);
|
||||
$date_pentecote = $date_paques + (3600 * 24 * 50);
|
||||
$jour_pentecote = gmdate("d", $date_pentecote);
|
||||
$mois_pentecote = gmdate("m", $date_pentecote);
|
||||
if ($jour_pentecote == $jour && $mois_pentecote == $mois) {
|
||||
@ -830,14 +804,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '',
|
||||
if (in_array('viernessanto', $specialdayrule)) {
|
||||
// Viernes Santo
|
||||
$date_paques = getGMTEasterDatetime($annee);
|
||||
$date_viernes = mktime(
|
||||
gmdate("H", $date_paques),
|
||||
gmdate("i", $date_paques),
|
||||
gmdate("s", $date_paques),
|
||||
gmdate("m", $date_paques),
|
||||
gmdate("d", $date_paques) - 2,
|
||||
gmdate("Y", $date_paques)
|
||||
);
|
||||
$date_viernes = $date_paques - (3600 * 24 * 2);
|
||||
$jour_viernes = gmdate("d", $date_viernes);
|
||||
$mois_viernes = gmdate("m", $date_viernes);
|
||||
if ($jour_viernes == $jour && $mois_viernes == $mois) {
|
||||
@ -849,14 +816,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '',
|
||||
if (in_array('fronleichnam', $specialdayrule)) {
|
||||
// Fronleichnam (60 days after easter sunday)
|
||||
$date_paques = getGMTEasterDatetime($annee);
|
||||
$date_fronleichnam = mktime(
|
||||
gmdate("H", $date_paques),
|
||||
gmdate("i", $date_paques),
|
||||
gmdate("s", $date_paques),
|
||||
gmdate("m", $date_paques),
|
||||
gmdate("d", $date_paques) + 60,
|
||||
gmdate("Y", $date_paques)
|
||||
);
|
||||
$date_fronleichnam = $date_paques + (3600 * 24 * 60);
|
||||
$jour_fronleichnam = gmdate("d", $date_fronleichnam);
|
||||
$mois_fronleichnam = gmdate("m", $date_fronleichnam);
|
||||
if ($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) {
|
||||
|
||||
@ -17,9 +17,15 @@ if (isset($totalarray['pos'])) {
|
||||
} else {
|
||||
if ($i == 1) {
|
||||
if ($num < $limit) {
|
||||
print '<td class="left">'.$langs->trans("Total").'</td>';
|
||||
print '<td>'.$langs->trans("Total").'</td>';
|
||||
} else {
|
||||
print '<td class="left">'.$langs->trans("Totalforthispage").'</td>';
|
||||
print '<td>';
|
||||
if (is_object($form)) {
|
||||
print $form->textwithpicto($langs->trans("Total"), $langs->transnoentitiesnoconv("Totalforthispage"));
|
||||
} else {
|
||||
print $langs->trans("Totalforthispage");
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
} else {
|
||||
print '<td></td>';
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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');
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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 ' ';
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
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;
|
||||
|
||||
@ -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(
|
||||
@ -124,18 +134,23 @@ $error = 0;
|
||||
* 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 = '';
|
||||
@ -150,8 +165,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');
|
||||
@ -164,8 +178,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) {
|
||||
@ -177,16 +190,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 {
|
||||
@ -202,8 +218,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"));
|
||||
}
|
||||
|
||||
@ -212,10 +227,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;
|
||||
}
|
||||
}
|
||||
@ -231,23 +244,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;
|
||||
}
|
||||
@ -255,11 +264,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;
|
||||
@ -270,8 +277,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 {
|
||||
@ -284,17 +290,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(
|
||||
@ -323,8 +340,7 @@ if (empty($reshook))
|
||||
|
||||
$rcp->add_object_linked('facture_fourn_det', $result);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$lineid = $result;
|
||||
} else {
|
||||
$lineid = 0;
|
||||
@ -332,8 +348,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;
|
||||
}
|
||||
}
|
||||
@ -343,22 +358,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;
|
||||
@ -376,8 +391,7 @@ if (empty($reshook))
|
||||
$massaction = $action = 'confirm_createbills';
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans('BillCreated', $nb_bills_created));
|
||||
} else {
|
||||
@ -413,60 +427,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);
|
||||
}
|
||||
}
|
||||
@ -476,8 +515,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);
|
||||
}
|
||||
@ -499,27 +537,58 @@ $reception = new Reception($db);
|
||||
$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 .= "&sall=".urlencode($sall);
|
||||
if ($search_ref_rcp) $param .= "&search_ref_rcp=".urlencode($search_ref_rcp);
|
||||
if ($search_ref_liv) $param .= "&search_ref_liv=".urlencode($search_ref_liv);
|
||||
if ($search_company) $param .= "&search_company=".urlencode($search_company);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if ($search_billed != '' && $search_billed >= 0) $param .= "&search_billed=".urlencode($search_billed);
|
||||
if ($search_town) $param .= "&search_town=".urlencode($search_town);
|
||||
if ($search_zip) $param .= "&search_zip=".urlencode($search_zip);
|
||||
if ($search_state) $param .= "&search_state=".urlencode($search_state);
|
||||
if ($search_status != '') $param .= "&search_status=".urlencode($search_status);
|
||||
if ($search_country) $param .= "&search_country=".urlencode($search_country);
|
||||
if ($search_type_thirdparty) $param .= "&search_type_thirdparty=".urlencode($search_type_thirdparty);
|
||||
if ($search_ref_supplier) $param .= "&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 .= "&sall=".urlencode($sall);
|
||||
}
|
||||
if ($search_ref_rcp) {
|
||||
$param .= "&search_ref_rcp=".urlencode($search_ref_rcp);
|
||||
}
|
||||
if ($search_ref_liv) {
|
||||
$param .= "&search_ref_liv=".urlencode($search_ref_liv);
|
||||
}
|
||||
if ($search_company) {
|
||||
$param .= "&search_company=".urlencode($search_company);
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
if ($search_billed != '' && $search_billed >= 0) {
|
||||
$param .= "&search_billed=".urlencode($search_billed);
|
||||
}
|
||||
if ($search_town) {
|
||||
$param .= "&search_town=".urlencode($search_town);
|
||||
}
|
||||
if ($search_zip) {
|
||||
$param .= "&search_zip=".urlencode($search_zip);
|
||||
}
|
||||
if ($search_state) {
|
||||
$param .= "&search_state=".urlencode($search_state);
|
||||
}
|
||||
if ($search_status != '') {
|
||||
$param .= "&search_status=".urlencode($search_status);
|
||||
}
|
||||
if ($search_country) {
|
||||
$param .= "&search_country=".urlencode($search_country);
|
||||
}
|
||||
if ($search_type_thirdparty) {
|
||||
$param .= "&search_type_thirdparty=".urlencode($search_type_thirdparty);
|
||||
}
|
||||
if ($search_ref_supplier) {
|
||||
$param .= "&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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -527,14 +596,20 @@ $arrayofmassactions = array(
|
||||
// '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">';
|
||||
@ -543,9 +618,7 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
|
||||
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">';
|
||||
|
||||
@ -571,8 +644,7 @@ if ($massaction == 'createbills')
|
||||
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 {
|
||||
@ -590,15 +662,15 @@ if ($massaction == 'createbills')
|
||||
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);
|
||||
@ -619,65 +691,60 @@ print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" :
|
||||
// --------------------------------------------------------------------
|
||||
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"> </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"> </td>';
|
||||
}
|
||||
@ -689,27 +756,23 @@ $parameters = array('arrayfields'=>$arrayfields);
|
||||
$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>';
|
||||
@ -722,34 +785,63 @@ print '</td>';
|
||||
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;
|
||||
@ -763,8 +855,7 @@ while ($i < min($num, $limit))
|
||||
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);
|
||||
@ -773,95 +864,104 @@ while ($i < min($num, $limit))
|
||||
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");
|
||||
@ -877,44 +977,52 @@ while ($i < min($num, $limit))
|
||||
$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";
|
||||
|
||||
@ -935,7 +1043,6 @@ if ($num == 0) {
|
||||
print "</table>";
|
||||
print "</div>";
|
||||
print '</form>';
|
||||
|
||||
$db->free($resql);
|
||||
|
||||
llxFooter();
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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).'&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).'&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
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
@ -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));
|
||||
|
||||
|
||||
@ -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));
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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&token='.newToken().'&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');
|
||||
|
||||
@ -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&token='.newToken().'&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');
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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++;
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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 .= '&socid='.$objthirdparty->id;
|
||||
if (get_class($objthirdparty) == 'Societe') {
|
||||
$out .= '&socid='.$objthirdparty->id;
|
||||
}
|
||||
$out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1&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"), '', '');
|
||||
|
||||
@ -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.'&action=delete&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';
|
||||
|
||||
@ -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'];
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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&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 .= '&socid='.$objthirdparty->id;
|
||||
if (get_class($objthirdparty) == 'Societe') {
|
||||
$out .= '&socid='.$objthirdparty->id;
|
||||
}
|
||||
$out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1&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"), '', '');
|
||||
|
||||
@ -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&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
|
||||
if ($permissiontoadd) {
|
||||
if ($action != 'classify') {
|
||||
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&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>';
|
||||
|
||||
@ -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&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
|
||||
if ($permissiontoadd) {
|
||||
if ($action != 'classify') {
|
||||
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&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';
|
||||
|
||||
@ -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&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.'">';
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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&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.'">';
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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.'&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.'&action=delete&token='.newToken().'" class="butActionDelete">'.$langs->trans('Delete').'</a>';
|
||||
print '</div>';
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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"> </option>'."\n";
|
||||
if ($showempty) {
|
||||
$out .= '<option value="-1"> </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").'"> ';
|
||||
|
||||
$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=""> </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=""> </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 : ' ';
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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'];
|
||||
}
|
||||
|
||||
|
||||
@ -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&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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 .= '&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);
|
||||
}
|
||||
|
||||
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>';
|
||||
}
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
@ -27,14 +27,17 @@ require '../../main.inc.php';
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
|
||||
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'salaries'));
|
||||
|
||||
// Security check
|
||||
if (!$user->admin)
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
@ -47,8 +50,7 @@ $list = array(
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
if ($action == 'update') {
|
||||
$error = 0;
|
||||
|
||||
foreach ($list as $constname) {
|
||||
@ -59,8 +61,7 @@ if ($action == 'update')
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
@ -74,7 +75,9 @@ if ($action == 'update')
|
||||
llxHeader('', $langs->trans('SalariesSetup'));
|
||||
|
||||
$form = new Form($db);
|
||||
if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$formaccounting = new FormAccounting($db);
|
||||
}
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans('SalariesSetup'), $linkback, 'title_setup');
|
||||
@ -99,8 +102,7 @@ print '<td>'.$langs->trans("Parameters").'</td>';
|
||||
print '<td width="60">'.$langs->trans("Value")."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ($list as $key)
|
||||
{
|
||||
foreach ($list as $key) {
|
||||
print '<tr class="oddeven value">';
|
||||
|
||||
// Param
|
||||
@ -109,8 +111,7 @@ foreach ($list as $key)
|
||||
|
||||
// Value
|
||||
print '<td>';
|
||||
if (!empty($conf->accounting->enabled))
|
||||
{
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
|
||||
} else {
|
||||
print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
|
||||
|
||||
@ -36,13 +36,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 = 'payment_salary'; //Must be the $table_element of the class that manage extrafield
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -77,8 +81,7 @@ print dol_get_fiche_end();
|
||||
|
||||
|
||||
// Buttons
|
||||
if ($action != 'create' && $action != 'edit')
|
||||
{
|
||||
if ($action != 'create' && $action != 'edit') {
|
||||
print '<div class="tabsAction">';
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute").'</a></div>';
|
||||
print "</div>";
|
||||
@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit')
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
print '<div name="topofform"></div><br>';
|
||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||
|
||||
@ -104,8 +106,7 @@ if ($action == 'create')
|
||||
/* Edition of an optional field */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
if ($action == 'edit' && !empty($attrname))
|
||||
{
|
||||
if ($action == 'edit' && !empty($attrname)) {
|
||||
print '<div name="topofform"></div><br>';
|
||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||
|
||||
|
||||
@ -31,15 +31,16 @@ require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("compta", "banks", "bills", "users", "salaries", "hrm"));
|
||||
if (!empty($conf->projet->enabled)) $langs->load("projects");
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$langs->load("projects");
|
||||
}
|
||||
|
||||
$id = GETPOST("id", 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
@ -54,7 +55,9 @@ $dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid", "int");
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'salaries', '', '', '');
|
||||
|
||||
$object = new PaymentSalary($db);
|
||||
@ -71,24 +74,23 @@ $hookmanager->initHooks(array('salarycard', 'globalcard'));
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($cancel)
|
||||
{
|
||||
if ($cancel) {
|
||||
header("Location: list.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Link to a project
|
||||
if ($action == 'classin' && $user->rights->banque->modifier)
|
||||
{
|
||||
if ($action == 'classin' && $user->rights->banque->modifier) {
|
||||
$object->fetch($id);
|
||||
$object->setProject($projectid);
|
||||
}
|
||||
|
||||
if ($action == 'add' && empty($cancel))
|
||||
{
|
||||
if ($action == 'add' && empty($cancel)) {
|
||||
$error = 0;
|
||||
|
||||
if (empty($datev)) $datev = $datep;
|
||||
if (empty($datev)) {
|
||||
$datev = $datep;
|
||||
}
|
||||
|
||||
$type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement', 'code', 'id', 1);
|
||||
|
||||
@ -113,41 +115,36 @@ if ($action == 'add' && empty($cancel))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||
if ($ret < 0) $error++;
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (empty($datep) || empty($datev) || empty($datesp) || empty($dateep))
|
||||
{
|
||||
if (empty($datep) || empty($datev) || empty($datesp) || empty($dateep)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->fk_user) || $object->fk_user < 0)
|
||||
{
|
||||
if (empty($object->fk_user) || $object->fk_user < 0) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (empty($type_payment) || $type_payment < 0)
|
||||
{
|
||||
if (empty($type_payment) || $type_payment < 0) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (empty($object->amount))
|
||||
{
|
||||
if (empty($object->amount)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (!empty($conf->banque->enabled) && !$object->accountid > 0)
|
||||
{
|
||||
if (!empty($conf->banque->enabled) && !$object->accountid > 0) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
$ret = $object->create($user);
|
||||
if ($ret > 0)
|
||||
{
|
||||
if ($ret > 0) {
|
||||
$db->commit();
|
||||
|
||||
if (GETPOST('saveandnew', 'alpha')) {
|
||||
@ -168,26 +165,23 @@ if ($action == 'add' && empty($cancel))
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
if ($object->rappro == 0)
|
||||
{
|
||||
if ($object->rappro == 0) {
|
||||
$db->begin();
|
||||
|
||||
$ret = $object->delete($user);
|
||||
if ($ret > 0)
|
||||
{
|
||||
if ($object->fk_bank)
|
||||
{
|
||||
if ($ret > 0) {
|
||||
if ($object->fk_bank) {
|
||||
$accountline = new AccountLine($db);
|
||||
$result = $accountline->fetch($object->fk_bank);
|
||||
if ($result > 0) $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
|
||||
if ($result > 0) {
|
||||
$result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
|
||||
}
|
||||
}
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
$db->commit();
|
||||
header("Location: ".DOL_URL_ROOT.'/salaries/list.php');
|
||||
exit;
|
||||
@ -213,27 +207,25 @@ if ($action == 'delete')
|
||||
llxHeader("", $langs->trans("SalaryPayment"));
|
||||
|
||||
$form = new Form($db);
|
||||
if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db);
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$formproject = new FormProjets($db);
|
||||
}
|
||||
|
||||
if ($id)
|
||||
{
|
||||
if ($id) {
|
||||
$object = new PaymentSalary($db);
|
||||
$result = $object->fetch($id);
|
||||
if ($result <= 0)
|
||||
{
|
||||
if ($result <= 0) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Create
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
$year_current = strftime("%Y", dol_now());
|
||||
$pastmonth = strftime("%m", dol_now()) - 1;
|
||||
$pastmonthyear = $year_current;
|
||||
if ($pastmonth == 0)
|
||||
{
|
||||
if ($pastmonth == 0) {
|
||||
$pastmonth = 12;
|
||||
$pastmonthyear--;
|
||||
}
|
||||
@ -247,8 +239,7 @@ if ($action == 'create')
|
||||
$datesp = dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
|
||||
$dateep = dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
|
||||
|
||||
if (empty($datesp) || empty($dateep)) // We define date_start and date_end
|
||||
{
|
||||
if (empty($datesp) || empty($dateep)) { // We define date_start and date_end
|
||||
$datesp = dol_get_first_day($pastmonthyear, $pastmonth, false); $dateep = dol_get_last_day($pastmonthyear, $pastmonth, false);
|
||||
}
|
||||
|
||||
@ -306,8 +297,7 @@ if ($action == 'create')
|
||||
print '</td></tr>';
|
||||
|
||||
// Bank
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>';
|
||||
$form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant
|
||||
@ -321,8 +311,7 @@ if ($action == 'create')
|
||||
print '</td></tr>';
|
||||
|
||||
// Number
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
// Number
|
||||
print '<tr><td><label for="num_payment">'.$langs->trans('Numero');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
@ -331,21 +320,19 @@ if ($action == 'create')
|
||||
}
|
||||
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
$formproject = new FormProjets($db);
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$formproject = new FormProjets($db);
|
||||
|
||||
print '<tr><td>'.$langs->trans("Project").'</td><td>';
|
||||
$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1);
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Project").'</td><td>';
|
||||
$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters = array();
|
||||
$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');
|
||||
}
|
||||
|
||||
@ -371,8 +358,7 @@ if ($action == 'create')
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($id)
|
||||
{
|
||||
if ($id) {
|
||||
$head = salaries_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'salary');
|
||||
@ -387,11 +373,9 @@ if ($id)
|
||||
$morehtmlref .= $langs->trans('Employee').' : '.$userstatic->getNomUrl(1);
|
||||
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
|
||||
if ($user->rights->salaries->write)
|
||||
{
|
||||
if ($user->rights->salaries->write) {
|
||||
if ($action != 'classify') {
|
||||
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
|
||||
}
|
||||
@ -450,10 +434,8 @@ if ($id)
|
||||
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
|
||||
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
if ($object->fk_account > 0)
|
||||
{
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
if ($object->fk_account > 0) {
|
||||
$bankline = new AccountLine($db);
|
||||
$bankline->fetch($object->fk_bank);
|
||||
|
||||
@ -479,10 +461,8 @@ if ($id)
|
||||
// Action buttons
|
||||
|
||||
print '<div class="tabsAction">'."\n";
|
||||
if ($object->rappro == 0)
|
||||
{
|
||||
if (!empty($user->rights->salaries->delete))
|
||||
{
|
||||
if ($object->rappro == 0) {
|
||||
if (!empty($user->rights->salaries->delete)) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
|
||||
} else {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a></div>';
|
||||
|
||||
@ -65,8 +65,11 @@ class SalariesStats extends Stats
|
||||
if ($this->socid) {
|
||||
$this->where .= " AND fk_soc = ".$this->socid;
|
||||
}
|
||||
if (is_array($this->userid) && count($this->userid) > 0) $this->where .= ' AND fk_user IN ('.join(',', $this->userid).')';
|
||||
elseif ($this->userid > 0) $this->where .= ' AND fk_user = '.$this->userid;
|
||||
if (is_array($this->userid) && count($this->userid) > 0) {
|
||||
$this->where .= ' AND fk_user IN ('.join(',', $this->userid).')';
|
||||
} elseif ($this->userid > 0) {
|
||||
$this->where .= ' AND fk_user = '.$this->userid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -45,7 +45,9 @@ $confirm = GETPOST('confirm', 'alpha');
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid", "int");
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'salaries', '', '', '');
|
||||
|
||||
|
||||
@ -54,12 +56,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 PaymentSalary($db);
|
||||
@ -84,8 +92,7 @@ $form = new Form($db);
|
||||
|
||||
llxHeader("", $langs->trans("SalaryPayment"));
|
||||
|
||||
if ($object->id)
|
||||
{
|
||||
if ($object->id) {
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$head = salaries_prepare_head($object);
|
||||
@ -95,8 +102,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'];
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,9 @@ $action = GETPOST('action', 'aZ09');
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST('socid', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'salaries', '', '', '');
|
||||
|
||||
|
||||
|
||||
@ -32,13 +32,19 @@ $langs->loadLangs(array("salaries", "companies"));
|
||||
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
|
||||
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
|
||||
|
||||
$userid = GETPOST('userid', 'int'); if ($userid < 0) $userid = 0;
|
||||
$socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0;
|
||||
$userid = GETPOST('userid', 'int'); if ($userid < 0) {
|
||||
$userid = 0;
|
||||
}
|
||||
$socid = GETPOST('socid', 'int'); if ($socid < 0) {
|
||||
$socid = 0;
|
||||
}
|
||||
$id = GETPOST('id', 'int');
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid", "int");
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'salaries', '', '', '');
|
||||
|
||||
$nowyear = strftime("%Y", dol_now());
|
||||
@ -80,12 +86,10 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=salariesstats&file=sala
|
||||
|
||||
$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++;
|
||||
}
|
||||
@ -112,12 +116,10 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=salariesstats&file=
|
||||
|
||||
$px2 = new DolGraph();
|
||||
$mesg = $px2->isGraphKo();
|
||||
if (!$mesg)
|
||||
{
|
||||
if (!$mesg) {
|
||||
$px2->SetData($data);
|
||||
$i = $startyear; $legend = array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
while ($i <= $endyear) {
|
||||
$legend[] = $i;
|
||||
$i++;
|
||||
}
|
||||
@ -143,12 +145,10 @@ $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=salariesstats&file=salari
|
||||
|
||||
$px3 = new DolGraph();
|
||||
$mesg = $px3->isGraphKo();
|
||||
if (!$mesg)
|
||||
{
|
||||
if (!$mesg) {
|
||||
$px3->SetData($data);
|
||||
$i = $startyear; $legend = array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
while ($i <= $endyear) {
|
||||
$legend[] = $i;
|
||||
$i++;
|
||||
}
|
||||
@ -173,7 +173,9 @@ $arrayyears = array();
|
||||
foreach ($data as $val) {
|
||||
$arrayyears[$val['year']] = $val['year'];
|
||||
}
|
||||
if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
|
||||
if (!count($arrayyears)) {
|
||||
$arrayyears[$nowyear] = $nowyear;
|
||||
}
|
||||
|
||||
|
||||
$h = 0;
|
||||
@ -203,7 +205,9 @@ print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0
|
||||
print '</td></tr>';
|
||||
// Year
|
||||
print '<tr><td>'.$langs->trans("Year").'</td><td>';
|
||||
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
|
||||
if (!in_array($year, $arrayyears)) {
|
||||
$arrayyears[$year] = $year;
|
||||
}
|
||||
arsort($arrayyears);
|
||||
print $form->selectarray('year', $arrayyears, $year, 0);
|
||||
print '</td></tr>';
|
||||
@ -222,11 +226,9 @@ print '<td class="right">'.$langs->trans("AmountAverage").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$oldyear = 0;
|
||||
foreach ($data as $val)
|
||||
{
|
||||
foreach ($data as $val) {
|
||||
$year = $val['year'];
|
||||
while ($year && $oldyear > $year + 1)
|
||||
{
|
||||
while ($year && $oldyear > $year + 1) {
|
||||
// If we have empty year
|
||||
$oldyear--;
|
||||
|
||||
@ -256,7 +258,9 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
|
||||
// Show graphs
|
||||
print '<table class="border centpercent"><tr class="pair nohover"><td align="center">';
|
||||
if ($mesg) { print $mesg; } else {
|
||||
if ($mesg) {
|
||||
print $mesg;
|
||||
} else {
|
||||
print $px1->show();
|
||||
print "<br>\n";
|
||||
print $px2->show();
|
||||
|
||||
@ -36,13 +36,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 = 'socpeople'; //Must be the $element of the class that manage extrafield
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -77,8 +81,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>";
|
||||
@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit')
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
print '<br><div id="newattrib"></div>';
|
||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||
|
||||
@ -104,8 +106,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));
|
||||
|
||||
|
||||
@ -35,7 +35,9 @@ $langs->loadLangs(array("admin", "companies", "other"));
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$value = GETPOST('value', 'alpha');
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
@ -47,10 +49,8 @@ $formcompany = new FormCompany($db);
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
if ($action == 'setcodeclient')
|
||||
{
|
||||
if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
if ($action == 'setcodeclient') {
|
||||
if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
@ -58,10 +58,8 @@ if ($action == 'setcodeclient')
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setcodecompta')
|
||||
{
|
||||
if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
if ($action == 'setcodecompta') {
|
||||
if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
@ -69,41 +67,40 @@ if ($action == 'setcodecompta')
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'updateoptions')
|
||||
{
|
||||
if (GETPOST('COMPANY_USE_SEARCH_TO_SELECT'))
|
||||
{
|
||||
if ($action == 'updateoptions') {
|
||||
if (GETPOST('COMPANY_USE_SEARCH_TO_SELECT')) {
|
||||
$companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT', 'alpha');
|
||||
$res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity);
|
||||
if (!($res > 0)) $error++;
|
||||
if (!$error)
|
||||
{
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if (GETPOST('CONTACT_USE_SEARCH_TO_SELECT'))
|
||||
{
|
||||
if (GETPOST('CONTACT_USE_SEARCH_TO_SELECT')) {
|
||||
$contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT', 'alpha');
|
||||
$res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch, 'chaine', 0, '', $conf->entity);
|
||||
if (!($res > 0)) $error++;
|
||||
if (!$error)
|
||||
{
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if (GETPOST('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT'))
|
||||
{
|
||||
if (GETPOST('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')) {
|
||||
$customertypedefault = GETPOST('defaultcustomertype', 'int');
|
||||
$res = dolibarr_set_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $customertypedefault, 'chaine', 0, '', $conf->entity);
|
||||
if (!($res > 0)) $error++;
|
||||
if (!$error)
|
||||
{
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
@ -112,8 +109,7 @@ if ($action == 'updateoptions')
|
||||
}
|
||||
|
||||
// Activate a document generator module
|
||||
if ($action == 'set')
|
||||
{
|
||||
if ($action == 'set') {
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$scandir = GETPOST('scan_dir', 'alpha');
|
||||
|
||||
@ -125,22 +121,24 @@ if ($action == 'set')
|
||||
$sql .= ")";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) dol_print_error($db);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// Disable a document generator module
|
||||
if ($action == 'del')
|
||||
{
|
||||
if ($action == 'del') {
|
||||
$type = 'company';
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE nom='".$db->escape($value)."' AND type='".$db->escape($type)."' AND entity=".$conf->entity;
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) dol_print_error($db);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// Define default generator
|
||||
if ($action == 'setdoc')
|
||||
{
|
||||
if ($action == 'setdoc') {
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$scandir = GETPOST('scan_dir', 'alpha');
|
||||
|
||||
@ -164,8 +162,7 @@ if ($action == 'setdoc')
|
||||
$sql .= ")";
|
||||
dol_syslog("societe.php", LOG_DEBUG);
|
||||
$result2 = $db->query($sql);
|
||||
if ($result1 && $result2)
|
||||
{
|
||||
if ($result1 && $result2) {
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
@ -176,9 +173,10 @@ if ($action == 'setdoc')
|
||||
if ($action == "setaddrefinlist") {
|
||||
$setaddrefinlist = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist, 'yesno', 0, '', $conf->entity);
|
||||
if (!($res > 0)) $error++;
|
||||
if (!$error)
|
||||
{
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
@ -189,9 +187,10 @@ if ($action == "setaddrefinlist") {
|
||||
if ($action == "setaddadressinlist") {
|
||||
$val = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
|
||||
if (!($res > 0)) $error++;
|
||||
if (!$error)
|
||||
{
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
@ -202,7 +201,9 @@ if ($action == "setaddadressinlist") {
|
||||
if ($action == "setaddemailphonetownincontactlist") {
|
||||
$val = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
|
||||
if (!($res > 0)) $error++;
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
@ -214,9 +215,10 @@ if ($action == "setaddemailphonetownincontactlist") {
|
||||
if ($action == "setaskforshippingmet") {
|
||||
$setaskforshippingmet = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet, 'yesno', 0, '', $conf->entity);
|
||||
if (!($res > 0)) $error++;
|
||||
if (!$error)
|
||||
{
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
@ -227,9 +229,10 @@ if ($action == "setaskforshippingmet") {
|
||||
if ($action == "setdisableprospectcustomer") {
|
||||
$setdisableprospectcustomer = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity);
|
||||
if (!($res > 0)) $error++;
|
||||
if (!$error)
|
||||
{
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
@ -237,13 +240,11 @@ if ($action == "setdisableprospectcustomer") {
|
||||
}
|
||||
|
||||
//Activate ProfId unique
|
||||
if ($action == 'setprofid')
|
||||
{
|
||||
if ($action == 'setprofid') {
|
||||
$status = GETPOST('status', 'alpha');
|
||||
|
||||
$idprof = "SOCIETE_".$value."_UNIQUE";
|
||||
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) {
|
||||
//header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
//exit;
|
||||
} else {
|
||||
@ -252,13 +253,11 @@ if ($action == 'setprofid')
|
||||
}
|
||||
|
||||
//Activate ProfId mandatory
|
||||
if ($action == 'setprofidmandatory')
|
||||
{
|
||||
if ($action == 'setprofidmandatory') {
|
||||
$status = GETPOST('status', 'alpha');
|
||||
|
||||
$idprof = "SOCIETE_".$value."_MANDATORY";
|
||||
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) {
|
||||
//header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
//exit;
|
||||
} else {
|
||||
@ -267,13 +266,11 @@ if ($action == 'setprofidmandatory')
|
||||
}
|
||||
|
||||
//Activate ProfId invoice mandatory
|
||||
if ($action == 'setprofidinvoicemandatory')
|
||||
{
|
||||
if ($action == 'setprofidinvoicemandatory') {
|
||||
$status = GETPOST('status', 'alpha');
|
||||
|
||||
$idprof = "SOCIETE_".$value."_INVOICE_MANDATORY";
|
||||
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) {
|
||||
//header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
//exit;
|
||||
} else {
|
||||
@ -282,12 +279,10 @@ if ($action == 'setprofidinvoicemandatory')
|
||||
}
|
||||
|
||||
//Set hide closed customer into combox or select
|
||||
if ($action == 'sethideinactivethirdparty')
|
||||
{
|
||||
if ($action == 'sethideinactivethirdparty') {
|
||||
$status = GETPOST('status', 'alpha');
|
||||
|
||||
if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
@ -297,9 +292,10 @@ if ($action == 'sethideinactivethirdparty')
|
||||
if ($action == 'setonsearchandlistgooncustomerorsuppliercard') {
|
||||
$setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity);
|
||||
if (!($res > 0)) $error++;
|
||||
if (!$error)
|
||||
{
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
@ -326,7 +322,9 @@ $head = societe_admin_prepare_head();
|
||||
print dol_get_fiche_head($head, 'general', $langs->trans("ThirdParties"), -1, 'company');
|
||||
|
||||
$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
|
||||
foreach ($conf->modules_parts['models'] as $mo) $dirsociete[] = $mo.'core/modules/societe/'; //Add more models
|
||||
foreach ($conf->modules_parts['models'] as $mo) {
|
||||
$dirsociete[] = $mo.'core/modules/societe/'; //Add more models
|
||||
}
|
||||
|
||||
// Module to manage customer/supplier code
|
||||
|
||||
@ -344,32 +342,31 @@ print "</tr>\n";
|
||||
|
||||
$arrayofmodules = array();
|
||||
|
||||
foreach ($dirsociete as $dirroot)
|
||||
{
|
||||
foreach ($dirsociete as $dirroot) {
|
||||
$dir = dol_buildpath($dirroot, 0);
|
||||
|
||||
$handle = @opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
if (is_resource($handle)) {
|
||||
// Loop on each module find in opened directory
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php')
|
||||
{
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php') {
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
try {
|
||||
dol_include_once($dirroot.$file.'.php');
|
||||
} catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
dol_syslog($e->getMessage(), LOG_ERR);
|
||||
}
|
||||
|
||||
$modCodeTiers = new $file;
|
||||
|
||||
// Show modules according to features level
|
||||
if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||
continue;
|
||||
}
|
||||
if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$arrayofmodules[$file] = $modCodeTiers;
|
||||
}
|
||||
@ -380,24 +377,26 @@ foreach ($dirsociete as $dirroot)
|
||||
|
||||
$arrayofmodules = dol_sort_array($arrayofmodules, 'position');
|
||||
|
||||
foreach ($arrayofmodules as $file => $modCodeTiers)
|
||||
{
|
||||
foreach ($arrayofmodules as $file => $modCodeTiers) {
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td width="140">'.$modCodeTiers->name.'</td>'."\n";
|
||||
print '<td>'.$modCodeTiers->info($langs).'</td>'."\n";
|
||||
print '<td class="nowrap">'.$modCodeTiers->getExample($langs).'</td>'."\n";
|
||||
|
||||
if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file")
|
||||
{
|
||||
if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") {
|
||||
print '<td class="center">'."\n";
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print "</td>\n";
|
||||
} else {
|
||||
$disabled = (!empty($conf->multicompany->enabled) && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false);
|
||||
print '<td class="center">';
|
||||
if (!$disabled) print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&token='.newToken().'&value='.urlencode($file).'">';
|
||||
if (!$disabled) {
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&token='.newToken().'&value='.urlencode($file).'">';
|
||||
}
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
if (!$disabled) print '</a>';
|
||||
if (!$disabled) {
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
@ -430,23 +429,18 @@ print "</tr>\n";
|
||||
|
||||
$arrayofmodules = array();
|
||||
|
||||
foreach ($dirsociete as $dirroot)
|
||||
{
|
||||
foreach ($dirsociete as $dirroot) {
|
||||
$dir = dol_buildpath($dirroot, 0);
|
||||
|
||||
$handle = @opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php')
|
||||
{
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php') {
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
try {
|
||||
dol_include_once($dirroot.$file.'.php');
|
||||
} catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
dol_syslog($e->getMessage(), LOG_ERR);
|
||||
}
|
||||
|
||||
@ -462,16 +456,14 @@ foreach ($dirsociete as $dirroot)
|
||||
$arrayofmodules = dol_sort_array($arrayofmodules, 'position');
|
||||
|
||||
|
||||
foreach ($arrayofmodules as $file => $modCodeCompta)
|
||||
{
|
||||
foreach ($arrayofmodules as $file => $modCodeCompta) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$modCodeCompta->name."</td><td>\n";
|
||||
print $modCodeCompta->info($langs);
|
||||
print '</td>';
|
||||
print '<td class="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n";
|
||||
|
||||
if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file")
|
||||
{
|
||||
if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file") {
|
||||
print '<td class="center">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</td>';
|
||||
@ -503,12 +495,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = 'company'";
|
||||
$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++;
|
||||
@ -527,24 +517,19 @@ print '<td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
|
||||
print '<td class="center" width="60">'.$langs->trans("Preview").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ($dirsociete as $dirroot)
|
||||
{
|
||||
foreach ($dirsociete as $dirroot) {
|
||||
$dir = dol_buildpath($dirroot.'doc/', 0);
|
||||
|
||||
$handle = @opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file))
|
||||
{
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
if (preg_match('/\.modules\.php$/i', $file)) {
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
try {
|
||||
dol_include_once($dirroot.'doc/'.$file);
|
||||
} catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
dol_syslog($e->getMessage(), LOG_ERR);
|
||||
}
|
||||
|
||||
@ -552,22 +537,26 @@ foreach ($dirsociete as $dirroot)
|
||||
|
||||
$modulequalified = 1;
|
||||
if (!empty($module->version)) {
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
|
||||
elseif ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||
$modulequalified = 0;
|
||||
} elseif ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($modulequalified)
|
||||
{
|
||||
if ($modulequalified) {
|
||||
print '<tr class="oddeven"><td width="100">';
|
||||
print $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>';
|
||||
|
||||
// Activate / Disable
|
||||
if (in_array($name, $def))
|
||||
{
|
||||
if (in_array($name, $def)) {
|
||||
print "<td class=\"center\">\n";
|
||||
//if ($conf->global->COMPANY_ADDON_PDF != "$name")
|
||||
//{
|
||||
@ -581,8 +570,7 @@ foreach ($dirsociete as $dirroot)
|
||||
//}
|
||||
print "</td>";
|
||||
} else {
|
||||
if (versioncompare($module->phpmin, versionphparray()) > 0)
|
||||
{
|
||||
if (versioncompare($module->phpmin, versionphparray()) > 0) {
|
||||
print '<td class="center">'."\n";
|
||||
print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion", join('.', $module->phpmin))), 'switch_off');
|
||||
print "</td>";
|
||||
@ -596,8 +584,7 @@ foreach ($dirsociete as $dirroot)
|
||||
// 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("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
|
||||
}
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
@ -609,8 +596,7 @@ foreach ($dirsociete as $dirroot)
|
||||
|
||||
// Preview
|
||||
print '<td class="center nowrap">';
|
||||
if ($module->type == 'pdf')
|
||||
{
|
||||
if ($module->type == 'pdf') {
|
||||
$linkspec = '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&token='.newToken().'&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
|
||||
} else {
|
||||
$linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
||||
@ -659,10 +645,8 @@ $profid['EMAIL'][0] = $langs->trans("EMail");
|
||||
$profid['EMAIL'][1] = $langs->trans('Email');
|
||||
|
||||
$nbofloop = count($profid);
|
||||
foreach ($profid as $key => $val)
|
||||
{
|
||||
if ($profid[$key][1] != '-')
|
||||
{
|
||||
foreach ($profid as $key => $val) {
|
||||
if ($profid[$key][1] != '-') {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$profid[$key][0]."</td><td>\n";
|
||||
print $profid[$key][1];
|
||||
@ -676,8 +660,7 @@ foreach ($profid as $key => $val)
|
||||
$mandatory = (empty($conf->global->$idprof_mandatory) ?false:true);
|
||||
$invoice_mandatory = (empty($conf->global->$idprof_invoice_mandatory) ?false:true);
|
||||
|
||||
if ($verif)
|
||||
{
|
||||
if ($verif) {
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
@ -687,8 +670,7 @@ foreach ($profid as $key => $val)
|
||||
print '</a></td>';
|
||||
}
|
||||
|
||||
if ($mandatory)
|
||||
{
|
||||
if ($mandatory) {
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&token='.newToken().'&value='.$key.'&status=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
@ -698,8 +680,7 @@ foreach ($profid as $key => $val)
|
||||
print '</a></td>';
|
||||
}
|
||||
|
||||
if ($invoice_mandatory)
|
||||
{
|
||||
if ($invoice_mandatory) {
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
@ -740,8 +721,7 @@ print '<td width="80"> </td></tr>'."\n";
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"), $langs->trans('UseSearchToSelectCompanyTooltip'), 1).' </td>';
|
||||
if (!$conf->use_javascript_ajax)
|
||||
{
|
||||
if (!$conf->use_javascript_ajax) {
|
||||
print '<td class="nowrap right" colspan="2">';
|
||||
print $langs->trans("NotAvailableWhenAjaxDisabled");
|
||||
print "</td>";
|
||||
@ -762,8 +742,7 @@ print '</tr>';
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"), $langs->trans('UseSearchToSelectContactTooltip'), 1).'</td>';
|
||||
if (!$conf->use_javascript_ajax)
|
||||
{
|
||||
if (!$conf->use_javascript_ajax) {
|
||||
print '<td class="nowrap right" colspan="2">';
|
||||
print $langs->trans("NotAvailableWhenAjaxDisabled");
|
||||
print "</td>";
|
||||
@ -787,8 +766,7 @@ print '<tr class="oddeven">';
|
||||
print '<td width="80%">'.$langs->trans("AddRefInList").'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td class="center">';
|
||||
if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST))
|
||||
{
|
||||
if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&token='.newToken().'&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
} else {
|
||||
@ -802,8 +780,7 @@ print '<tr class="oddeven">';
|
||||
print '<td width="80%">'.$langs->trans("AddAdressInList").'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td class="center">';
|
||||
if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST))
|
||||
{
|
||||
if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&token='.newToken().'&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
} else {
|
||||
@ -833,8 +810,7 @@ if (!empty($conf->expedition->enabled)) {
|
||||
print '<td width="80%">'.$langs->trans("AskForPreferredShippingMethod").'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td class="center">';
|
||||
if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD))
|
||||
{
|
||||
if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) {
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&token='.newToken().'&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
} else {
|
||||
@ -851,8 +827,7 @@ print '<tr class="oddeven">';
|
||||
print '<td width="80%">'.$langs->trans("DisableProspectCustomerType").'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td class="center">';
|
||||
if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS))
|
||||
{
|
||||
if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&token='.newToken().'&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
} else {
|
||||
|
||||
@ -36,13 +36,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 = 'societe'; //Must be the $element of the class that manage extrafield
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -77,8 +81,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>";
|
||||
@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit')
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
print '<br><div id="newattrib"></div>';
|
||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||
|
||||
@ -104,8 +106,7 @@ if ($action == 'create')
|
||||
/* Edition d'un champ optionnel */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
if ($action == 'edit' && !empty($attrname))
|
||||
{
|
||||
if ($action == 'edit' && !empty($attrname)) {
|
||||
print '<br><div id="editattrib"></div>';
|
||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||
|
||||
|
||||
@ -34,10 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
$langs->loadLangs(array("companies", "bills", "propal", "orders"));
|
||||
|
||||
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));
|
||||
}
|
||||
@ -45,19 +46,27 @@ $search_agenda_label = GETPOST('search_agenda_label');
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST('socid', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'societe', $socid, '&societe');
|
||||
|
||||
$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 object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('agendathirdparty'));
|
||||
@ -69,20 +78,19 @@ $hookmanager->initHooks(array('agendathirdparty'));
|
||||
|
||||
$parameters = array('id'=>$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');
|
||||
}
|
||||
|
||||
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 = '';
|
||||
}
|
||||
@ -96,8 +104,7 @@ if (empty($reshook))
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
if ($socid > 0)
|
||||
{
|
||||
if ($socid > 0) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
|
||||
@ -105,10 +112,14 @@ if ($socid > 0)
|
||||
$result = $object->fetch($socid);
|
||||
|
||||
$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;
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
|
||||
$title = $object->name." - ".$title;
|
||||
}
|
||||
llxHeader('', $title);
|
||||
|
||||
if (!empty($conf->notification->enabled)) $langs->load("mails");
|
||||
if (!empty($conf->notification->enabled)) {
|
||||
$langs->load("mails");
|
||||
}
|
||||
$head = societe_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, 'company');
|
||||
@ -137,29 +148,31 @@ if ($socid > 0)
|
||||
|
||||
$out = '';
|
||||
$permok = $user->rights->agenda->myactions->create;
|
||||
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok)
|
||||
{
|
||||
if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : ''));
|
||||
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
|
||||
if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') {
|
||||
$out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : ''));
|
||||
}
|
||||
$out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&percentage=-1';
|
||||
$out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog');
|
||||
}
|
||||
|
||||
$newcardbutton = '';
|
||||
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)) {
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
|
||||
}
|
||||
}
|
||||
|
||||
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))) {
|
||||
print '<br>';
|
||||
|
||||
$param = '&socid='.$socid;
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.$contextpage;
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.$limit;
|
||||
}
|
||||
|
||||
print load_fiche_titre($langs->trans("ActionsOnCompany"), $newcardbutton, '');
|
||||
//print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1);
|
||||
|
||||
@ -22,12 +22,24 @@
|
||||
* \brief File to return Ajax response on thirdparty list request
|
||||
*/
|
||||
|
||||
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
|
||||
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
||||
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
||||
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
||||
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
|
||||
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
define('NOTOKENRENEWAL', 1); // Disables token renewal
|
||||
}
|
||||
if (!defined('NOREQUIREMENU')) {
|
||||
define('NOREQUIREMENU', '1');
|
||||
}
|
||||
if (!defined('NOREQUIREHTML')) {
|
||||
define('NOREQUIREHTML', '1');
|
||||
}
|
||||
if (!defined('NOREQUIREAJAX')) {
|
||||
define('NOREQUIREAJAX', '1');
|
||||
}
|
||||
if (!defined('NOREQUIRESOC')) {
|
||||
define('NOREQUIRESOC', '1');
|
||||
}
|
||||
if (!defined('NOCSRFCHECK')) {
|
||||
define('NOCSRFCHECK', '1');
|
||||
}
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
@ -48,16 +60,14 @@ $showtype = GETPOST('showtype', 'int');
|
||||
dol_syslog(join(',', $_GET));
|
||||
//print_r($_GET);
|
||||
|
||||
if (!empty($action) && $action == 'fetch' && !empty($id))
|
||||
{
|
||||
if (!empty($action) && $action == 'fetch' && !empty($id)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
|
||||
$outjson = array();
|
||||
|
||||
$object = new Societe($db);
|
||||
$ret = $object->fetch($id);
|
||||
if ($ret > 0)
|
||||
{
|
||||
if ($ret > 0) {
|
||||
$outref = $object->ref;
|
||||
$outname = $object->name;
|
||||
$outdesc = '';
|
||||
@ -74,7 +84,9 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
|
||||
|
||||
top_httphead();
|
||||
|
||||
if (empty($htmlname)) return;
|
||||
if (empty($htmlname)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET));
|
||||
sort($match);
|
||||
@ -83,12 +95,18 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
|
||||
// When used from jQuery, the search term is added as GET param "term".
|
||||
$searchkey = (($id && GETPOST($id, 'alpha')) ?GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : ''));
|
||||
|
||||
if (!$searchkey) return;
|
||||
if (!$searchkey) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_object($form)) $form = new Form($db);
|
||||
if (!is_object($form)) {
|
||||
$form = new Form($db);
|
||||
}
|
||||
$arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson);
|
||||
|
||||
$db->close();
|
||||
|
||||
if ($outjson) print json_encode($arrayresult);
|
||||
if ($outjson) {
|
||||
print json_encode($arrayresult);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,12 +23,24 @@
|
||||
* \brief File to return Ajax response on third parties request
|
||||
*/
|
||||
|
||||
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
|
||||
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
||||
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
||||
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
||||
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
|
||||
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
define('NOTOKENRENEWAL', 1); // Disables token renewal
|
||||
}
|
||||
if (!defined('NOREQUIREMENU')) {
|
||||
define('NOREQUIREMENU', '1');
|
||||
}
|
||||
if (!defined('NOREQUIREHTML')) {
|
||||
define('NOREQUIREHTML', '1');
|
||||
}
|
||||
if (!defined('NOREQUIREAJAX')) {
|
||||
define('NOREQUIREAJAX', '1');
|
||||
}
|
||||
if (!defined('NOREQUIRESOC')) {
|
||||
define('NOREQUIRESOC', '1');
|
||||
}
|
||||
if (!defined('NOCSRFCHECK')) {
|
||||
define('NOCSRFCHECK', '1');
|
||||
}
|
||||
|
||||
require '../main.inc.php';
|
||||
|
||||
@ -50,24 +62,25 @@ dol_syslog(join(',', $_GET));
|
||||
|
||||
|
||||
// Generation liste des societes
|
||||
if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn'))
|
||||
{
|
||||
if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) {
|
||||
$return_arr = array();
|
||||
|
||||
// Define filter on text typed
|
||||
$socid = $_GET['newcompany'] ? $_GET['newcompany'] : '';
|
||||
if (!$socid) $socid = $_GET['socid'] ? $_GET['socid'] : '';
|
||||
if (!$socid) $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : '';
|
||||
if (!$socid) {
|
||||
$socid = $_GET['socid'] ? $_GET['socid'] : '';
|
||||
}
|
||||
if (!$socid) {
|
||||
$socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : '';
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid, nom";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE s.entity IN (".getEntity('societe').")";
|
||||
if ($socid)
|
||||
{
|
||||
if ($socid) {
|
||||
$sql .= " AND (";
|
||||
// Add criteria on name/code
|
||||
if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index
|
||||
{
|
||||
if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) { // Can use index
|
||||
$sql .= "nom LIKE '".$db->escape($socid)."%'";
|
||||
$sql .= " OR code_client LIKE '".$db->escape($socid)."%'";
|
||||
$sql .= " OR code_fournisseur LIKE '".$db->escape($socid)."%'";
|
||||
@ -76,7 +89,9 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn'))
|
||||
$sql .= " OR code_client LIKE '%".$db->escape($socid)."%'";
|
||||
$sql .= " OR code_fournisseur LIKE '%".$db->escape($socid)."%'";
|
||||
}
|
||||
if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) $sql .= " OR rowid = '".$db->escape($socid)."'";
|
||||
if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) {
|
||||
$sql .= " OR rowid = '".$db->escape($socid)."'";
|
||||
}
|
||||
$sql .= ")";
|
||||
}
|
||||
//if (GETPOST("filter")) $sql.= " AND (".GETPOST("filter", "alpha").")"; // Add other filters
|
||||
@ -84,12 +99,12 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn'))
|
||||
|
||||
//dol_syslog("ajaxcompanies", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($row = $db->fetch_array($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
while ($row = $db->fetch_array($resql)) {
|
||||
$label = $row['nom'];
|
||||
if ($socid) $label = preg_replace('/('.preg_quote($socid, '/').')/i', '<strong>$1</strong>', $label, 1);
|
||||
if ($socid) {
|
||||
$label = preg_replace('/('.preg_quote($socid, '/').')/i', '<strong>$1</strong>', $label, 1);
|
||||
}
|
||||
$row_array['label'] = $label;
|
||||
$row_array['value'] = $row['nom'];
|
||||
$row_array['key'] = $row['rowid'];
|
||||
|
||||
@ -22,12 +22,24 @@
|
||||
* \brief File to return Ajax response on country request
|
||||
*/
|
||||
|
||||
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
|
||||
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
||||
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
||||
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
||||
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
|
||||
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
define('NOTOKENRENEWAL', 1); // Disables token renewal
|
||||
}
|
||||
if (!defined('NOREQUIREMENU')) {
|
||||
define('NOREQUIREMENU', '1');
|
||||
}
|
||||
if (!defined('NOREQUIREHTML')) {
|
||||
define('NOREQUIREHTML', '1');
|
||||
}
|
||||
if (!defined('NOREQUIREAJAX')) {
|
||||
define('NOREQUIREAJAX', '1');
|
||||
}
|
||||
if (!defined('NOREQUIRESOC')) {
|
||||
define('NOREQUIRESOC', '1');
|
||||
}
|
||||
if (!defined('NOCSRFCHECK')) {
|
||||
define('NOCSRFCHECK', '1');
|
||||
}
|
||||
|
||||
require '../main.inc.php';
|
||||
|
||||
@ -50,8 +62,7 @@ print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"])
|
||||
dol_syslog(join(',', $_POST));
|
||||
|
||||
// Generate list of countries
|
||||
if (!empty($country))
|
||||
{
|
||||
if (!empty($country)) {
|
||||
global $langs;
|
||||
$langs->load("dict");
|
||||
|
||||
@ -61,11 +72,9 @@ if (!empty($country))
|
||||
$sql .= " ORDER BY label ASC";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
print '<ul>';
|
||||
while ($country = $db->fetch_object($resql))
|
||||
{
|
||||
while ($country = $db->fetch_object($resql)) {
|
||||
print '<li>';
|
||||
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
|
||||
print ($country->code && $langs->trans("Country".$country->code) != "Country".$country->code ? $langs->trans("Country".$country->code) : ($country->label != '-' ? $country->label : ' '));
|
||||
|
||||
@ -66,7 +66,9 @@ abstract class ActionsCardCommon
|
||||
//$ret = $this->getInstanceDao();
|
||||
|
||||
$object = new Societe($this->db);
|
||||
if (!empty($id) || !empty($ref)) $object->fetch($id, $ref);
|
||||
if (!empty($id) || !empty($ref)) {
|
||||
$object->fetch($id, $ref);
|
||||
}
|
||||
$this->object = $object;
|
||||
}
|
||||
|
||||
@ -85,26 +87,37 @@ abstract class ActionsCardCommon
|
||||
global $conf, $langs, $db, $user, $mysoc, $canvas;
|
||||
global $form, $formadmin, $formcompany;
|
||||
|
||||
if ($action == 'add' || $action == 'update') $this->assign_post($action);
|
||||
if ($action == 'add' || $action == 'update') {
|
||||
$this->assign_post($action);
|
||||
}
|
||||
|
||||
if ($_GET["type"] == 'f') { $this->object->fournisseur = 1; }
|
||||
if ($_GET["type"] == 'c') { $this->object->client = 1; }
|
||||
if ($_GET["type"] == 'p') { $this->object->client = 2; }
|
||||
if ($_GET["type"] == 'cp') { $this->object->client = 3; }
|
||||
if ($_REQUEST["private"] == 1) { $this->object->particulier = 1; }
|
||||
if ($_GET["type"] == 'f') {
|
||||
$this->object->fournisseur = 1;
|
||||
}
|
||||
if ($_GET["type"] == 'c') {
|
||||
$this->object->client = 1;
|
||||
}
|
||||
if ($_GET["type"] == 'p') {
|
||||
$this->object->client = 2;
|
||||
}
|
||||
if ($_GET["type"] == 'cp') {
|
||||
$this->object->client = 3;
|
||||
}
|
||||
if ($_REQUEST["private"] == 1) {
|
||||
$this->object->particulier = 1;
|
||||
}
|
||||
|
||||
foreach ($this->object as $key => $value)
|
||||
{
|
||||
foreach ($this->object as $key => $value) {
|
||||
$this->tpl[$key] = $value;
|
||||
}
|
||||
|
||||
$this->tpl['error'] = get_htmloutput_errors($this->object->error, $this->object->errors);
|
||||
if (is_array($GLOBALS['errors'])) $this->tpl['error'] = get_htmloutput_mesg('', $GLOBALS['errors'], 'error');
|
||||
if (is_array($GLOBALS['errors'])) {
|
||||
$this->tpl['error'] = get_htmloutput_mesg('', $GLOBALS['errors'], 'error');
|
||||
}
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
if ($action == 'create') {
|
||||
if ($conf->use_javascript_ajax) {
|
||||
$this->tpl['ajax_selecttype'] = "\n".'<script type="text/javascript" language="javascript">
|
||||
$(document).ready(function () {
|
||||
$("#radiocompany").click(function() {
|
||||
@ -124,10 +137,8 @@ abstract class ActionsCardCommon
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'create' || $action == 'edit')
|
||||
{
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
if ($action == 'create' || $action == 'edit') {
|
||||
if ($conf->use_javascript_ajax) {
|
||||
$this->tpl['ajax_selectcountry'] = "\n".'<script type="text/javascript" language="javascript">
|
||||
$(document).ready(function () {
|
||||
$("#selectcountry_id").change(function() {
|
||||
@ -141,20 +152,22 @@ abstract class ActionsCardCommon
|
||||
|
||||
// Load object modCodeClient
|
||||
$module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard');
|
||||
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
|
||||
{
|
||||
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
|
||||
$module = substr($module, 0, dol_strlen($module) - 4);
|
||||
}
|
||||
$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
|
||||
foreach ($dirsociete as $dirroot)
|
||||
{
|
||||
foreach ($dirsociete as $dirroot) {
|
||||
$res = dol_include_once($dirroot.$module.'.php');
|
||||
if ($res) break;
|
||||
if ($res) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$modCodeClient = new $module($db);
|
||||
$this->tpl['auto_customercode'] = $modCodeClient->code_auto;
|
||||
// We verified if the tag prefix is used
|
||||
if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
|
||||
if ($modCodeClient->code_auto) {
|
||||
$this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
|
||||
}
|
||||
|
||||
// TODO create a function
|
||||
$this->tpl['select_customertype'] = Form::selectarray('client', array(
|
||||
@ -166,36 +179,41 @@ abstract class ActionsCardCommon
|
||||
|
||||
// Customer
|
||||
$this->tpl['customercode'] = $this->object->code_client;
|
||||
if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) $this->tpl['customercode'] = $modCodeClient->getNextValue($this->object, 0);
|
||||
if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) {
|
||||
$this->tpl['customercode'] = $modCodeClient->getNextValue($this->object, 0);
|
||||
}
|
||||
$this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable();
|
||||
$s = $modCodeClient->getToolTip($langs, $this->object, 0);
|
||||
$this->tpl['help_customercode'] = $form->textwithpicto('', $s, 1);
|
||||
|
||||
if (!empty($conf->fournisseur->enabled))
|
||||
{
|
||||
if (!empty($conf->fournisseur->enabled)) {
|
||||
$this->tpl['supplier_enabled'] = 1;
|
||||
|
||||
// Load object modCodeFournisseur
|
||||
$module = $conf->global->SOCIETE_CODECLIENT_ADDON;
|
||||
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
|
||||
{
|
||||
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
|
||||
$module = substr($module, 0, dol_strlen($module) - 4);
|
||||
}
|
||||
$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
|
||||
foreach ($dirsociete as $dirroot)
|
||||
{
|
||||
foreach ($dirsociete as $dirroot) {
|
||||
$res = dol_include_once($dirroot.$module.'.php');
|
||||
if ($res) break;
|
||||
if ($res) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$modCodeFournisseur = new $module;
|
||||
$this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto;
|
||||
// We verified if the tag prefix is used
|
||||
if ($modCodeFournisseur->code_auto) $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
|
||||
if ($modCodeFournisseur->code_auto) {
|
||||
$this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
|
||||
}
|
||||
|
||||
// Supplier
|
||||
$this->tpl['yn_supplier'] = $form->selectyesno("fournisseur", $this->object->fournisseur, 1);
|
||||
$this->tpl['suppliercode'] = $this->object->code_fournisseur;
|
||||
if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object, 1);
|
||||
if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
|
||||
$this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object, 1);
|
||||
}
|
||||
$this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable();
|
||||
$s = $modCodeFournisseur->getToolTip($langs, $this->object, 1);
|
||||
$this->tpl['help_suppliercode'] = $form->textwithpicto('', $s, 1);
|
||||
@ -216,14 +234,21 @@ abstract class ActionsCardCommon
|
||||
$this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id');
|
||||
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||
|
||||
if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
if ($user->admin) {
|
||||
$this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
}
|
||||
|
||||
// State
|
||||
if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
|
||||
else $this->tpl['select_state'] = $countrynotdefined;
|
||||
if ($this->object->country_id) {
|
||||
$this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
|
||||
} else {
|
||||
$this->tpl['select_state'] = $countrynotdefined;
|
||||
}
|
||||
|
||||
// Language
|
||||
if (!empty($conf->global->MAIN_MULTILANGS)) $this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang ? $this->object->default_lang : $conf->global->MAIN_LANG_DEFAULT), 'default_lang', 0, 0, 1);
|
||||
if (!empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang ? $this->object->default_lang : $conf->global->MAIN_LANG_DEFAULT), 'default_lang', 0, 0, 1);
|
||||
}
|
||||
|
||||
// VAT
|
||||
$this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value', $this->tpl['tva_assuj'], 1); // Assujeti par defaut en creation
|
||||
@ -233,24 +258,20 @@ abstract class ActionsCardCommon
|
||||
|
||||
// Local Tax
|
||||
// TODO mettre dans une classe propre au pays
|
||||
if ($mysoc->country_code == 'ES')
|
||||
{
|
||||
if ($mysoc->country_code == 'ES') {
|
||||
$this->tpl['localtax'] = '';
|
||||
|
||||
if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1")
|
||||
{
|
||||
if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
|
||||
$this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td>';
|
||||
$this->tpl['localtax'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1);
|
||||
$this->tpl['localtax'] .= '</td><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td>';
|
||||
$this->tpl['localtax'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1);
|
||||
$this->tpl['localtax'] .= '</td></tr>';
|
||||
} elseif ($mysoc->localtax1_assuj == "1")
|
||||
{
|
||||
} elseif ($mysoc->localtax1_assuj == "1") {
|
||||
$this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
|
||||
$this->tpl['localtax'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1);
|
||||
$this->tpl['localtax'] .= '</td><tr>';
|
||||
} elseif ($mysoc->localtax2_assuj == "1")
|
||||
{
|
||||
} elseif ($mysoc->localtax2_assuj == "1") {
|
||||
$this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
|
||||
$this->tpl['localtax'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1);
|
||||
$this->tpl['localtax'] .= '</td><tr>';
|
||||
@ -269,7 +290,9 @@ abstract class ActionsCardCommon
|
||||
$this->tpl['address'] = dol_nl2br($this->object->address);
|
||||
|
||||
$img = picto_from_langcode($this->object->country_code);
|
||||
if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img ? $img.' ' : '').$this->object->country, $langs->trans("CountryIsInEEC"), 1, 0);
|
||||
if ($this->object->isInEEC()) {
|
||||
$this->tpl['country'] = $form->textwithpicto(($img ? $img.' ' : '').$this->object->country, $langs->trans("CountryIsInEEC"), 1, 0);
|
||||
}
|
||||
$this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country;
|
||||
|
||||
$this->tpl['phone'] = dol_print_phone($this->object->phone, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
|
||||
@ -283,8 +306,7 @@ abstract class ActionsCardCommon
|
||||
$arr = $formcompany->typent_array(1);
|
||||
$this->tpl['typent'] = $arr[$this->object->typent_code];
|
||||
|
||||
if (!empty($conf->global->MAIN_MULTILANGS))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_MULTILANGS)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
//$s=picto_from_langcode($this->default_lang);
|
||||
//print ($s?$s.' ':'');
|
||||
@ -300,31 +322,31 @@ abstract class ActionsCardCommon
|
||||
$this->tpl['sales_representatives'] = '';
|
||||
$listsalesrepresentatives = $this->object->getSalesRepresentatives($user);
|
||||
$nbofsalesrepresentative = count($listsalesrepresentatives);
|
||||
if ($nbofsalesrepresentative > 3) // We print only number
|
||||
{
|
||||
if ($nbofsalesrepresentative > 3) { // We print only number
|
||||
$this->tpl['sales_representatives'] .= $nbofsalesrepresentative;
|
||||
} elseif ($nbofsalesrepresentative > 0) {
|
||||
$userstatic = new User($this->db);
|
||||
$i = 0;
|
||||
foreach ($listsalesrepresentatives as $val)
|
||||
{
|
||||
foreach ($listsalesrepresentatives as $val) {
|
||||
$userstatic->id = $val['id'];
|
||||
$userstatic->lastname = $val['name'];
|
||||
$userstatic->firstname = $val['firstname'];
|
||||
$this->tpl['sales_representatives'] .= $userstatic->getNomUrl(1);
|
||||
$i++;
|
||||
if ($i < $nbofsalesrepresentative) $this->tpl['sales_representatives'] .= ', ';
|
||||
if ($i < $nbofsalesrepresentative) {
|
||||
$this->tpl['sales_representatives'] .= ', ';
|
||||
}
|
||||
}
|
||||
} else $this->tpl['sales_representatives'] .= $langs->trans("NoSalesRepresentativeAffected");
|
||||
} else {
|
||||
$this->tpl['sales_representatives'] .= $langs->trans("NoSalesRepresentativeAffected");
|
||||
}
|
||||
|
||||
// Linked member
|
||||
if (!empty($conf->adherent->enabled))
|
||||
{
|
||||
if (!empty($conf->adherent->enabled)) {
|
||||
$langs->load("members");
|
||||
$adh = new Adherent($this->db);
|
||||
$result = $adh->fetch('', '', $this->object->id);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$adh->ref = $adh->getFullName($langs);
|
||||
$this->tpl['linked_member'] = $adh->getNomUrl(1);
|
||||
} else {
|
||||
@ -334,22 +356,18 @@ abstract class ActionsCardCommon
|
||||
|
||||
// Local Tax
|
||||
// TODO mettre dans une classe propre au pays
|
||||
if ($mysoc->country_code == 'ES')
|
||||
{
|
||||
if ($mysoc->country_code == 'ES') {
|
||||
$this->tpl['localtax'] = '';
|
||||
|
||||
if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1")
|
||||
{
|
||||
if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
|
||||
$this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>';
|
||||
$this->tpl['localtax'] .= '<td>'.yn($this->object->localtax1_assuj).'</td>';
|
||||
$this->tpl['localtax'] .= '<td>'.$langs->trans("LocalTax2IsUsedES").'</td>';
|
||||
$this->tpl['localtax'] .= '<td>'.yn($this->object->localtax2_assuj).'</td></tr>';
|
||||
} elseif ($mysoc->localtax1_assuj == "1")
|
||||
{
|
||||
} elseif ($mysoc->localtax1_assuj == "1") {
|
||||
$this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>';
|
||||
$this->tpl['localtax'] .= '<td colspan="3">'.yn($this->object->localtax1_assuj).'</td></tr>';
|
||||
} elseif ($mysoc->localtax2_assuj == "1")
|
||||
{
|
||||
} elseif ($mysoc->localtax2_assuj == "1") {
|
||||
$this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td>';
|
||||
$this->tpl['localtax'] .= '<td colspan="3">'.yn($this->object->localtax2_assuj).'</td></tr>';
|
||||
}
|
||||
@ -405,8 +423,7 @@ abstract class ActionsCardCommon
|
||||
$this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
|
||||
|
||||
// We set country_id, and country_code label of the chosen country
|
||||
if ($this->object->country_id)
|
||||
{
|
||||
if ($this->object->country_id) {
|
||||
$tmparray = getCountry($this->object->country_id, 'all', $this->db, $langs, 0);
|
||||
$this->object->country_code = $tmparray['code'];
|
||||
$this->object->country_label = $tmparray['label'];
|
||||
|
||||
@ -61,9 +61,15 @@ class ActionsCardCompany extends ActionsCardCommon
|
||||
|
||||
$out = '';
|
||||
|
||||
if ($action == 'view') $out .= $langs->trans("ThirdParty");
|
||||
if ($action == 'edit') $out .= $langs->trans("EditCompany");
|
||||
if ($action == 'create') $out .= $langs->trans("NewCompany");
|
||||
if ($action == 'view') {
|
||||
$out .= $langs->trans("ThirdParty");
|
||||
}
|
||||
if ($action == 'edit') {
|
||||
$out .= $langs->trans("EditCompany");
|
||||
}
|
||||
if ($action == 'create') {
|
||||
$out .= $langs->trans("NewCompany");
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
@ -95,8 +101,7 @@ class ActionsCardCompany extends ActionsCardCommon
|
||||
$this->tpl['profid3'] = $this->object->idprof3;
|
||||
$this->tpl['profid4'] = $this->object->idprof4;
|
||||
|
||||
if ($conf->use_javascript_ajax && empty($conf->global->MAIN_DISABLEVATCHECK))
|
||||
{
|
||||
if ($conf->use_javascript_ajax && empty($conf->global->MAIN_DISABLEVATCHECK)) {
|
||||
$js = "\n";
|
||||
$js .= '<script language="JavaScript" type="text/javascript">';
|
||||
$js .= "function CheckVAT(a) {\n";
|
||||
@ -107,10 +112,8 @@ class ActionsCardCompany extends ActionsCardCommon
|
||||
$this->tpl['js_checkVatPopup'] = $js;
|
||||
}
|
||||
|
||||
if ($action == 'create' || $action == 'edit')
|
||||
{
|
||||
for ($i = 1; $i <= 4; $i++)
|
||||
{
|
||||
if ($action == 'create' || $action == 'edit') {
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
$this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i, $this->object->country_code);
|
||||
$this->tpl['showprofid'.$i] = $formcompany->get_input_id_prof($i, 'idprof'.$i, $this->tpl['profid'.$i], $this->object->country_code);
|
||||
}
|
||||
@ -126,12 +129,10 @@ class ActionsCardCompany extends ActionsCardCommon
|
||||
|
||||
// VAT intra
|
||||
$s = '<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">';
|
||||
if (empty($conf->global->MAIN_DISABLEVATCHECK))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLEVATCHECK)) {
|
||||
$s .= ' ';
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
if ($conf->use_javascript_ajax) {
|
||||
$s .= '<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
|
||||
$this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
|
||||
} else {
|
||||
@ -142,29 +143,24 @@ class ActionsCardCompany extends ActionsCardCommon
|
||||
}
|
||||
} else {
|
||||
// Confirm delete third party
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
$this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "1,action-delete");
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 4; $i++)
|
||||
{
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
$this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i, $this->object->country_code);
|
||||
$this->tpl['checkprofid'.$i] = $this->object->id_prof_check($i, $this->object);
|
||||
$this->tpl['urlprofid'.$i] = $this->object->id_prof_url($i, $this->object);
|
||||
}
|
||||
|
||||
// TVA intra
|
||||
if ($this->object->tva_intra)
|
||||
{
|
||||
if ($this->object->tva_intra) {
|
||||
$s = $this->object->tva_intra;
|
||||
$s .= '<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">';
|
||||
if (empty($conf->global->MAIN_DISABLEVATCHECK))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLEVATCHECK)) {
|
||||
$s .= ' ';
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
if ($conf->use_javascript_ajax) {
|
||||
$s .= '<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
|
||||
$this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
|
||||
} else {
|
||||
@ -178,8 +174,7 @@ class ActionsCardCompany extends ActionsCardCommon
|
||||
}
|
||||
|
||||
// Parent company
|
||||
if ($this->object->parent)
|
||||
{
|
||||
if ($this->object->parent) {
|
||||
$socm = new Societe($this->db);
|
||||
$socm->fetch($this->object->parent);
|
||||
$this->tpl['parent_company'] = $socm->getNomUrl(1).' '.($socm->code_client ? "(".$socm->code_client.")" : "");
|
||||
|
||||
@ -17,8 +17,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;
|
||||
}
|
||||
@ -43,7 +42,9 @@ if (empty($conf) || !is_object($conf))
|
||||
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?>
|
||||
<?php if ($this->control->tpl['js_checkVatPopup']) {
|
||||
echo $this->control->tpl['js_checkVatPopup'];
|
||||
} ?>
|
||||
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" name="formsoc">
|
||||
|
||||
@ -61,17 +62,17 @@ if (empty($conf) || !is_object($conf))
|
||||
<td><span class="fieldrequired"><?php echo $langs->trans('ThirdPartyName'); ?></span></td>
|
||||
<td><input type="text" size="30" maxlength="60" name="nom" value="<?php echo $this->control->tpl['nom']; ?>"></td>
|
||||
<?php if (!empty($conf->global->SOCIETE_USEPREFIX)) { ?>
|
||||
<td><?php echo $langs->trans('Prefix'); ?></td>
|
||||
<td><input type="text" size="5" maxlength="5" name="prefix_comm" value="<?php echo $this->control->tpl['prefix_comm']; ?>"></td>
|
||||
<?php } ?>
|
||||
<td><?php echo $langs->trans('Prefix'); ?></td>
|
||||
<td><input type="text" size="5" maxlength="5" name="prefix_comm" value="<?php echo $this->control->tpl['prefix_comm']; ?>"></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td width="25%"><span class="fieldrequired"><?php echo $langs->trans('ProspectCustomer'); ?></span></td>
|
||||
<td width="25%"><?php echo $this->control->tpl['select_customertype']; ?></td>
|
||||
|
||||
<td width="25%"><?php echo $langs->trans('CustomerCode'); ?></td>
|
||||
<td width="25%">
|
||||
<td width="25%"><?php echo $langs->trans('CustomerCode'); ?></td>
|
||||
<td width="25%">
|
||||
<table class="nobordernopadding">
|
||||
<tr>
|
||||
<td><input type="text" name="code_client" size="16" value="<?php echo $this->control->tpl['customercode']; ?>" maxlength="15"></td>
|
||||
@ -85,14 +86,14 @@ if (empty($conf) || !is_object($conf))
|
||||
<tr>
|
||||
<td><span class="fieldrequired"><?php echo $langs->trans('Supplier'); ?></span></td>
|
||||
<td><?php echo $this->control->tpl['yn_supplier']; ?></td>
|
||||
<td><?php echo $langs->trans('SupplierCode'); ?></td>
|
||||
<td>
|
||||
<table class="nobordernopadding">
|
||||
<tr>
|
||||
<td><input type="text" name="code_fournisseur" size="16" value="<?php echo $this->control->tpl['suppliercode']; ?>" maxlength="15"></td>
|
||||
<td><?php echo $this->control->tpl['help_suppliercode']; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<td><?php echo $langs->trans('SupplierCode'); ?></td>
|
||||
<td>
|
||||
<table class="nobordernopadding">
|
||||
<tr>
|
||||
<td><input type="text" name="code_fournisseur" size="16" value="<?php echo $this->control->tpl['suppliercode']; ?>" maxlength="15"></td>
|
||||
<td><?php echo $this->control->tpl['help_suppliercode']; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -155,15 +156,23 @@ if (!empty($conf->barcode->enabled)) { ?>
|
||||
<?php
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
if ($this->control->tpl['langprofid'.$i] != '-') {
|
||||
if ($i == 1 || $i == 3) echo '<tr>';
|
||||
if ($i == 1 || $i == 3) {
|
||||
echo '<tr>';
|
||||
}
|
||||
echo '<td>'.$this->control->tpl['langprofid'.$i].'</td>';
|
||||
echo '<td>'.$this->control->tpl['showprofid'.$i].'</td>';
|
||||
if ($i == 2 || $i == 4) echo '</tr>';
|
||||
if ($i == 2 || $i == 4) {
|
||||
echo '</tr>';
|
||||
}
|
||||
} else {
|
||||
if ($i == 1 || $i == 3) echo '<tr>';
|
||||
if ($i == 1 || $i == 3) {
|
||||
echo '<tr>';
|
||||
}
|
||||
echo '<td> </td>';
|
||||
echo '<td> </td>';
|
||||
if ($i == 2 || $i == 4) echo '</tr>';
|
||||
if ($i == 2 || $i == 4) {
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -194,7 +203,9 @@ for ($i = 1; $i <= 4; $i++) {
|
||||
<td class="nowrap"><?php echo $this->control->tpl['tva_intra']; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
|
||||
<?php if (!empty($this->control->tpl['localtax'])) {
|
||||
echo $this->control->tpl['localtax'];
|
||||
} ?>
|
||||
|
||||
<?php if ($user->rights->societe->client->voir) { ?>
|
||||
<tr>
|
||||
|
||||
@ -17,8 +17,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;
|
||||
}
|
||||
@ -34,7 +33,9 @@ $contact = $GLOBALS['objcanvas']->control->object;
|
||||
<?php echo $this->control->tpl['error']; ?>
|
||||
|
||||
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
|
||||
<?php if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?>
|
||||
<?php if ($this->control->tpl['js_checkVatPopup']) {
|
||||
echo $this->control->tpl['js_checkVatPopup'];
|
||||
} ?>
|
||||
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"].'?socid='.$this->control->tpl['id']; ?>" method="POST" name="formsoc">
|
||||
<input type="hidden" name="canvas" value="<?php echo $canvas ?>">
|
||||
@ -165,15 +166,23 @@ if (!empty($conf->barcode->enabled)) { ?>
|
||||
<?php
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
if ($this->control->tpl['langprofid'.$i] != '-') {
|
||||
if ($i == 1 || $i == 3) echo '<tr>';
|
||||
if ($i == 1 || $i == 3) {
|
||||
echo '<tr>';
|
||||
}
|
||||
echo '<td>'.$this->control->tpl['langprofid'.$i].'</td>';
|
||||
echo '<td>'.$this->control->tpl['showprofid'.$i].'</td>';
|
||||
if ($i == 2 || $i == 4) echo '</tr>';
|
||||
if ($i == 2 || $i == 4) {
|
||||
echo '</tr>';
|
||||
}
|
||||
} else {
|
||||
if ($i == 1 || $i == 3) echo '<tr>';
|
||||
if ($i == 1 || $i == 3) {
|
||||
echo '<tr>';
|
||||
}
|
||||
echo '<td> </td>';
|
||||
echo '<td> </td>';
|
||||
if ($i == 2 || $i == 4) echo '</tr>';
|
||||
if ($i == 2 || $i == 4) {
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -209,7 +218,9 @@ for ($i = 1; $i <= 4; $i++) {
|
||||
</tr>
|
||||
<?php }
|
||||
|
||||
if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
|
||||
if (!empty($this->control->tpl['localtax'])) {
|
||||
echo $this->control->tpl['localtax'];
|
||||
} ?>
|
||||
|
||||
</table>
|
||||
<br>
|
||||
|
||||
@ -16,8 +16,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;
|
||||
}
|
||||
@ -34,9 +33,15 @@ print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company
|
||||
|
||||
?>
|
||||
|
||||
<?php if ($this->control->tpl['error']) echo $this->control->tpl['error']; ?>
|
||||
<?php if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?>
|
||||
<?php if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?>
|
||||
<?php if ($this->control->tpl['error']) {
|
||||
echo $this->control->tpl['error'];
|
||||
} ?>
|
||||
<?php if ($this->control->tpl['action_delete']) {
|
||||
echo $this->control->tpl['action_delete'];
|
||||
} ?>
|
||||
<?php if ($this->control->tpl['js_checkVatPopup']) {
|
||||
echo $this->control->tpl['js_checkVatPopup'];
|
||||
} ?>
|
||||
|
||||
<table class="border allwidth">
|
||||
|
||||
@ -120,20 +125,31 @@ print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company
|
||||
<?php
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
if ($this->control->tpl['langprofid'.$i] != '-') {
|
||||
if ($i == 1 || $i == 3) echo '<tr>';
|
||||
if ($i == 1 || $i == 3) {
|
||||
echo '<tr>';
|
||||
}
|
||||
echo '<td>'.$this->control->tpl['langprofid'.$i].'</td>';
|
||||
echo '<td>'.$this->control->tpl['profid'.$i];
|
||||
if ($this->control->tpl['profid'.$i]) {
|
||||
if ($this->control->tpl['checkprofid'.$i] > 0) echo ' '.$this->control->tpl['urlprofid'.$i];
|
||||
else echo ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
|
||||
if ($this->control->tpl['checkprofid'.$i] > 0) {
|
||||
echo ' '.$this->control->tpl['urlprofid'.$i];
|
||||
} else {
|
||||
echo ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
|
||||
}
|
||||
}
|
||||
echo '</td>';
|
||||
if ($i == 2 || $i == 4) echo '</tr>';
|
||||
if ($i == 2 || $i == 4) {
|
||||
echo '</tr>';
|
||||
}
|
||||
} else {
|
||||
if ($i == 1 || $i == 3) echo '<tr>';
|
||||
if ($i == 1 || $i == 3) {
|
||||
echo '<tr>';
|
||||
}
|
||||
echo '<td> </td>';
|
||||
echo '<td> </td>';
|
||||
if ($i == 2 || $i == 4) echo '</tr>';
|
||||
if ($i == 2 || $i == 4) {
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -145,14 +161,19 @@ for ($i = 1; $i <= 4; $i++) {
|
||||
<td><?php echo $this->control->tpl['tva_intra']; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
|
||||
<?php if (!empty($this->control->tpl['localtax'])) {
|
||||
echo $this->control->tpl['localtax'];
|
||||
} ?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans('Capital'); ?></td>
|
||||
<td colspan="3">
|
||||
<?php
|
||||
if ($this->control->tpl['capital']) echo $this->control->tpl['capital'].' '.$langs->trans("Currency".$conf->currency);
|
||||
else echo ' ';
|
||||
if ($this->control->tpl['capital']) {
|
||||
echo $this->control->tpl['capital'].' '.$langs->trans("Currency".$conf->currency);
|
||||
} else {
|
||||
echo ' ';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -61,9 +61,15 @@ class ActionsCardIndividual extends ActionsCardCommon
|
||||
|
||||
$out = '';
|
||||
|
||||
if ($action == 'view') $out .= $langs->trans("Individual");
|
||||
if ($action == 'edit') $out .= $langs->trans("EditCompany");
|
||||
if ($action == 'create') $out .= $langs->trans("NewCompany");
|
||||
if ($action == 'view') {
|
||||
$out .= $langs->trans("Individual");
|
||||
}
|
||||
if ($action == 'edit') {
|
||||
$out .= $langs->trans("EditCompany");
|
||||
}
|
||||
if ($action == 'create') {
|
||||
$out .= $langs->trans("NewCompany");
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
@ -107,13 +113,11 @@ class ActionsCardIndividual extends ActionsCardCommon
|
||||
|
||||
$this->tpl['title'] = load_fiche_titre($this->getTitle($action));
|
||||
|
||||
if ($action == 'create' || $action == 'edit')
|
||||
{
|
||||
if ($action == 'create' || $action == 'edit') {
|
||||
$this->tpl['select_civility'] = $formcompany->select_civility(GETPOST('civility_id'));
|
||||
} else {
|
||||
// Confirm delete third party
|
||||
if ($action == 'delete' || $conf->use_javascript_ajax)
|
||||
{
|
||||
if ($action == 'delete' || $conf->use_javascript_ajax) {
|
||||
$this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id, $langs->trans("DeleteAnIndividual"), $langs->trans("ConfirmDeleteIndividual"), "confirm_delete", '', 0, "1,action-delete");
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,8 +17,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;
|
||||
}
|
||||
@ -32,15 +31,15 @@ if (empty($conf) || !is_object($conf))
|
||||
<?php echo $this->control->tpl['error']; ?>
|
||||
|
||||
<?php if ($conf->use_javascript_ajax) { ?>
|
||||
<?php echo $this->control->tpl['ajax_selecttype']; ?>
|
||||
<?php echo $this->control->tpl['ajax_selecttype']; ?>
|
||||
<br>
|
||||
<?php echo $langs->trans("ThirdPartyType") ?>:
|
||||
<?php echo $langs->trans("ThirdPartyType") ?>:
|
||||
<input type="radio" id="radiocompany" class="flat" name="private" value="0">
|
||||
<?php echo $langs->trans("CompanyFoundation"); ?>
|
||||
<?php echo $langs->trans("CompanyFoundation"); ?>
|
||||
<input type="radio" id="radioprivate" class="flat" name="private" value="1" checked> <?php echo $langs->trans("Individual"); ?> (<?php echo $langs->trans("ToCreateContactWithSameName") ?>)
|
||||
<br>
|
||||
<br>
|
||||
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
|
||||
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
|
||||
<?php } ?>
|
||||
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" name="formsoc">
|
||||
@ -80,8 +79,8 @@ if (empty($conf) || !is_object($conf))
|
||||
<td width="25%"><span class="fieldrequired"><?php echo $langs->trans('ProspectCustomer'); ?></span></td>
|
||||
<td width="25%"><?php echo $this->control->tpl['select_customertype']; ?></td>
|
||||
|
||||
<td width="25%"><?php echo $langs->trans('CustomerCode'); ?></td>
|
||||
<td width="25%">
|
||||
<td width="25%"><?php echo $langs->trans('CustomerCode'); ?></td>
|
||||
<td width="25%">
|
||||
<table class="nobordernopadding">
|
||||
<tr>
|
||||
<td><input type="text" name="code_client" size="16" value="<?php echo $this->control->tpl['customercode']; ?>" maxlength="15"></td>
|
||||
@ -95,23 +94,23 @@ if (empty($conf) || !is_object($conf))
|
||||
<tr>
|
||||
<td><span class="fieldrequired"><?php echo $langs->trans('Supplier'); ?></span></td>
|
||||
<td><?php echo $this->control->tpl['yn_supplier']; ?></td>
|
||||
<td><?php echo $langs->trans('SupplierCode'); ?></td>
|
||||
<td>
|
||||
<table class="nobordernopadding">
|
||||
<tr>
|
||||
<td><input type="text" name="code_fournisseur" size="16" value="<?php echo $this->control->tpl['suppliercode']; ?>" maxlength="15"></td>
|
||||
<td><?php echo $this->control->tpl['help_suppliercode']; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<td><?php echo $langs->trans('SupplierCode'); ?></td>
|
||||
<td>
|
||||
<table class="nobordernopadding">
|
||||
<tr>
|
||||
<td><input type="text" name="code_fournisseur" size="16" value="<?php echo $this->control->tpl['suppliercode']; ?>" maxlength="15"></td>
|
||||
<td><?php echo $this->control->tpl['help_suppliercode']; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if (count($this->control->tpl['suppliercategory']) > 0) { ?>
|
||||
<?php if (count($this->control->tpl['suppliercategory']) > 0) { ?>
|
||||
<tr>
|
||||
<td><?php echo $langs->trans('SupplierCategory'); ?></td>
|
||||
<td colspan="3"><?php echo $this->control->tpl['select_suppliercategory']; ?></td>
|
||||
</tr>
|
||||
<?php }
|
||||
<?php }
|
||||
}
|
||||
|
||||
if (!empty($conf->barcode->enabled)) { ?>
|
||||
@ -169,7 +168,9 @@ if (!empty($conf->barcode->enabled)) { ?>
|
||||
<td colspan="3"><?php echo $this->control->tpl['yn_assujtva']; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
|
||||
<?php if (!empty($this->control->tpl['localtax'])) {
|
||||
echo $this->control->tpl['localtax'];
|
||||
} ?>
|
||||
|
||||
<?php if ($user->rights->societe->client->voir) { ?>
|
||||
<tr>
|
||||
|
||||
@ -17,8 +17,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;
|
||||
}
|
||||
@ -173,7 +172,9 @@ if ($this->control->tpl['fournisseur']) {
|
||||
<td colspan="3"><?php echo $this->control->tpl['yn_assujtva']; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
|
||||
<?php if (!empty($this->control->tpl['localtax'])) {
|
||||
echo $this->control->tpl['localtax'];
|
||||
} ?>
|
||||
|
||||
</table>
|
||||
<br>
|
||||
|
||||
@ -16,8 +16,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;
|
||||
}
|
||||
@ -32,8 +31,12 @@ $head = societe_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company');
|
||||
|
||||
if ($this->control->tpl['error']) echo $this->control->tpl['error'];
|
||||
if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?>
|
||||
if ($this->control->tpl['error']) {
|
||||
echo $this->control->tpl['error'];
|
||||
}
|
||||
if ($this->control->tpl['action_delete']) {
|
||||
echo $this->control->tpl['action_delete'];
|
||||
} ?>
|
||||
|
||||
<table class="border allwidth">
|
||||
|
||||
@ -119,7 +122,9 @@ if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delet
|
||||
<td colspan="3"><?php echo $this->control->tpl['tva_assuj']; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
|
||||
<?php if (!empty($this->control->tpl['localtax'])) {
|
||||
echo $this->control->tpl['localtax'];
|
||||
} ?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Type"); ?></td>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -45,8 +45,7 @@ print load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"), '', 'title_se
|
||||
|
||||
$vatNumber = GETPOST("vatNumber", 'alpha');
|
||||
|
||||
if (!$vatNumber)
|
||||
{
|
||||
if (!$vatNumber) {
|
||||
print '<br>';
|
||||
print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired", $langs->trans("VATIntraShort")).'</font><br>';
|
||||
} else {
|
||||
@ -76,8 +75,7 @@ if (!$vatNumber)
|
||||
|
||||
// Check for an error
|
||||
$err = $soapclient->getError();
|
||||
if ($err)
|
||||
{
|
||||
if ($err) {
|
||||
dol_syslog("Constructor error ".$WS_DOL_URL, LOG_ERR);
|
||||
}
|
||||
|
||||
@ -96,42 +94,38 @@ if (!$vatNumber)
|
||||
print '<b>'.$langs->trans("Response").'</b>:<br>';
|
||||
|
||||
// Service indisponible
|
||||
if (!is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i', $result['faultstring']))
|
||||
{
|
||||
if (!is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i', $result['faultstring'])) {
|
||||
print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
|
||||
$messagetoshow = $soapclient->response;
|
||||
} elseif (preg_match('/TIMEOUT/i', $result['faultstring']))
|
||||
{
|
||||
} elseif (preg_match('/TIMEOUT/i', $result['faultstring'])) {
|
||||
print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
|
||||
$messagetoshow = $soapclient->response;
|
||||
} elseif (preg_match('/SERVER_BUSY/i', $result['faultstring']))
|
||||
{
|
||||
} elseif (preg_match('/SERVER_BUSY/i', $result['faultstring'])) {
|
||||
print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
|
||||
$messagetoshow = $soapclient->response;
|
||||
} elseif ($result['faultstring'])
|
||||
{
|
||||
} elseif ($result['faultstring']) {
|
||||
print '<font class="error">'.$langs->trans("Error").'</font><br>';
|
||||
$messagetoshow = $result['faultstring'];
|
||||
}
|
||||
// Syntaxe ko
|
||||
elseif (preg_match('/INVALID_INPUT/i', $result['faultstring'])
|
||||
|| ($result['requestDate'] && !$result['valid']))
|
||||
{
|
||||
if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
|
||||
} elseif (preg_match('/INVALID_INPUT/i', $result['faultstring'])
|
||||
|| ($result['requestDate'] && !$result['valid'])) {
|
||||
// Syntaxe ko
|
||||
if ($result['requestDate']) {
|
||||
print $langs->trans("Date").': '.$result['requestDate'].'<br>';
|
||||
}
|
||||
print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
|
||||
print $langs->trans("ValueIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
|
||||
//$messagetoshow=$soapclient->response;
|
||||
} else {
|
||||
// Syntaxe ok
|
||||
if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
|
||||
if ($result['requestDate']) {
|
||||
print $langs->trans("Date").': '.$result['requestDate'].'<br>';
|
||||
}
|
||||
print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>';
|
||||
print $langs->trans("ValueIsValid").': ';
|
||||
if (preg_match('/MS_UNAVAILABLE/i', $result['faultstring']))
|
||||
{
|
||||
if (preg_match('/MS_UNAVAILABLE/i', $result['faultstring'])) {
|
||||
print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE", $countryCode).'</font><br>';
|
||||
} else {
|
||||
if (!empty($result['valid']) && ($result['valid'] == 1 || $result['valid'] == 'true'))
|
||||
{
|
||||
if (!empty($result['valid']) && ($result['valid'] == 1 || $result['valid'] == 'true')) {
|
||||
print '<font class="ok">'.$langs->trans("Yes").'</font>';
|
||||
print '<br>';
|
||||
print $langs->trans("Name").': '.$result['name'].'<br>';
|
||||
@ -144,10 +138,10 @@ if (!$vatNumber)
|
||||
}
|
||||
|
||||
// Show log data into page
|
||||
print "\n";
|
||||
print '<!-- ';
|
||||
var_dump($result);
|
||||
print '-->';
|
||||
// print "\n";
|
||||
// print '<!-- ';
|
||||
// var_dump($result);
|
||||
// print '-->';
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
@ -155,8 +149,7 @@ print $langs->trans("VATIntraManualCheck", $langs->trans("VATIntraCheckURL"), $l
|
||||
print '<br>';
|
||||
print '<div class="center"><input type="button" class="button" value="'.$langs->trans("CloseWindow").'" onclick="javascript: window.close()"></div>';
|
||||
|
||||
if ($messagetoshow)
|
||||
{
|
||||
if ($messagetoshow) {
|
||||
print '<br><br>';
|
||||
print "\n".'Error returned:<br>';
|
||||
print nl2br($messagetoshow);
|
||||
|
||||
@ -34,7 +34,7 @@ class Contacts extends DolibarrApi
|
||||
*
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
public static $FIELDS = array(
|
||||
'lastname',
|
||||
);
|
||||
|
||||
@ -71,8 +71,7 @@ class Contacts extends DolibarrApi
|
||||
*/
|
||||
public function get($id, $includecount = 0, $includeroles = 0)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
|
||||
throw new RestException(401, 'No permission to read contacts');
|
||||
}
|
||||
if ($id == 0) {
|
||||
@ -81,23 +80,19 @@ class Contacts extends DolibarrApi
|
||||
$result = $this->contact->fetch($id);
|
||||
}
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Contact not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
|
||||
{
|
||||
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
if ($includecount)
|
||||
{
|
||||
if ($includecount) {
|
||||
$this->contact->load_ref_elements();
|
||||
}
|
||||
|
||||
if ($includeroles)
|
||||
{
|
||||
if ($includeroles) {
|
||||
$this->contact->fetchRoles();
|
||||
}
|
||||
|
||||
@ -119,8 +114,7 @@ class Contacts extends DolibarrApi
|
||||
*/
|
||||
public function getByEmail($email, $includecount = 0, $includeroles = 0)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
|
||||
throw new RestException(401, 'No permission to read contacts');
|
||||
}
|
||||
if (empty($email)) {
|
||||
@ -129,23 +123,19 @@ class Contacts extends DolibarrApi
|
||||
$result = $this->contact->fetch('', '', '', $email);
|
||||
}
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Contact not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
|
||||
{
|
||||
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
if ($includecount)
|
||||
{
|
||||
if ($includecount) {
|
||||
$this->contact->load_ref_elements();
|
||||
}
|
||||
|
||||
if ($includeroles)
|
||||
{
|
||||
if ($includeroles) {
|
||||
$this->contact->fetchRoles();
|
||||
}
|
||||
|
||||
@ -176,8 +166,7 @@ class Contacts extends DolibarrApi
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
|
||||
throw new RestException(401, 'No permission to read contacts');
|
||||
}
|
||||
|
||||
@ -186,8 +175,9 @@ class Contacts extends DolibarrApi
|
||||
|
||||
// If the internal user must only see his customers, force searching by him
|
||||
$search_sale = 0;
|
||||
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)
|
||||
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
|
||||
$search_sale = DolibarrApiAccess::$user->id;
|
||||
}
|
||||
|
||||
$sql = "SELECT t.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
|
||||
@ -201,15 +191,18 @@ class Contacts extends DolibarrApi
|
||||
}
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON t.fk_soc = s.rowid";
|
||||
$sql .= ' WHERE t.entity IN ('.getEntity('socpeople').')';
|
||||
if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
|
||||
if ($socids) {
|
||||
$sql .= " AND t.fk_soc IN (".$socids.")";
|
||||
}
|
||||
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0)
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
|
||||
$sql .= " AND t.fk_soc = sc.fk_soc";
|
||||
if ($search_sale > 0)
|
||||
}
|
||||
if ($search_sale > 0) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||
}
|
||||
// Insert sale filter
|
||||
if ($search_sale > 0)
|
||||
{
|
||||
if ($search_sale > 0) {
|
||||
$sql .= " AND sc.fk_user = ".$search_sale;
|
||||
}
|
||||
|
||||
@ -220,10 +213,8 @@ class Contacts extends DolibarrApi
|
||||
}
|
||||
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -232,10 +223,8 @@ class Contacts extends DolibarrApi
|
||||
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit)
|
||||
{
|
||||
if ($page < 0)
|
||||
{
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
@ -243,24 +232,19 @@ class Contacts extends DolibarrApi
|
||||
$sql .= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
$i = 0;
|
||||
while ($i < $min)
|
||||
{
|
||||
while ($i < $min) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$contact_static = new Contact($this->db);
|
||||
if ($contact_static->fetch($obj->rowid))
|
||||
{
|
||||
if ($contact_static->fetch($obj->rowid)) {
|
||||
$contact_static->fetchRoles();
|
||||
if ($includecount)
|
||||
{
|
||||
if ($includecount) {
|
||||
$contact_static->load_ref_elements();
|
||||
}
|
||||
if ($includeroles)
|
||||
{
|
||||
if ($includeroles) {
|
||||
$contact_static->fetchRoles();
|
||||
}
|
||||
|
||||
@ -272,8 +256,7 @@ class Contacts extends DolibarrApi
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieve contacts : '.$sql);
|
||||
}
|
||||
if (!count($obj_ret))
|
||||
{
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'Contacts not found');
|
||||
}
|
||||
return $obj_ret;
|
||||
@ -287,15 +270,13 @@ class Contacts extends DolibarrApi
|
||||
*/
|
||||
public function post($request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
|
||||
throw new RestException(401, 'No permission to create/update contacts');
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
foreach ($request_data as $field => $value)
|
||||
{
|
||||
foreach ($request_data as $field => $value) {
|
||||
$this->contact->$field = $value;
|
||||
}
|
||||
if ($this->contact->create(DolibarrApiAccess::$user) < 0) {
|
||||
@ -313,30 +294,29 @@ class Contacts extends DolibarrApi
|
||||
*/
|
||||
public function put($id, $request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
|
||||
throw new RestException(401, 'No permission to create/update contacts');
|
||||
}
|
||||
|
||||
$result = $this->contact->fetch($id);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Contact not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
|
||||
{
|
||||
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
foreach ($request_data as $field => $value)
|
||||
{
|
||||
if ($field == 'id') continue;
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') {
|
||||
continue;
|
||||
}
|
||||
$this->contact->$field = $value;
|
||||
}
|
||||
|
||||
if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
|
||||
if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) {
|
||||
return $this->get($id);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -349,18 +329,15 @@ class Contacts extends DolibarrApi
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer) {
|
||||
throw new RestException(401, 'No permission to delete contacts');
|
||||
}
|
||||
$result = $this->contact->fetch($id);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Contact not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
|
||||
{
|
||||
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$this->contact->oldcopy = clone $this->contact;
|
||||
@ -382,10 +359,12 @@ class Contacts extends DolibarrApi
|
||||
//throw new RestException(401);
|
||||
//}
|
||||
|
||||
if (!isset($request_data["login"]))
|
||||
if (!isset($request_data["login"])) {
|
||||
throw new RestException(400, "login field missing");
|
||||
if (!isset($request_data["password"]))
|
||||
}
|
||||
if (!isset($request_data["password"])) {
|
||||
throw new RestException(400, "password field missing");
|
||||
}
|
||||
|
||||
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
|
||||
throw new RestException(401, 'No permission to read contacts');
|
||||
|
||||
@ -33,7 +33,7 @@ class Thirdparties extends DolibarrApi
|
||||
*
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
public static $FIELDS = array(
|
||||
'name'
|
||||
);
|
||||
|
||||
@ -137,46 +137,68 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
// If the internal user must only see his customers, force searching by him
|
||||
$search_sale = 0;
|
||||
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
|
||||
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
|
||||
$search_sale = DolibarrApiAccess::$user->id;
|
||||
}
|
||||
|
||||
$sql = "SELECT t.rowid";
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
|
||||
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||
}
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as t";
|
||||
if ($category > 0) {
|
||||
if ($mode != 4) $sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c";
|
||||
if (!in_array($mode, array(1, 2, 3))) $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cc";
|
||||
if ($mode != 4) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c";
|
||||
}
|
||||
if (!in_array($mode, array(1, 2, 3))) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cc";
|
||||
}
|
||||
}
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||
}
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||
$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||
$sql .= " WHERE t.entity IN (".getEntity('societe').")";
|
||||
$sql .= " AND t.fk_stcomm = st.id";
|
||||
|
||||
if ($mode == 1) $sql .= " AND t.client IN (1, 3)";
|
||||
elseif ($mode == 2) $sql .= " AND t.client IN (2, 3)";
|
||||
elseif ($mode == 3) $sql .= " AND t.client IN (0)";
|
||||
elseif ($mode == 4) $sql .= " AND t.fournisseur IN (1)";
|
||||
if ($mode == 1) {
|
||||
$sql .= " AND t.client IN (1, 3)";
|
||||
} elseif ($mode == 2) {
|
||||
$sql .= " AND t.client IN (2, 3)";
|
||||
} elseif ($mode == 3) {
|
||||
$sql .= " AND t.client IN (0)";
|
||||
} elseif ($mode == 4) {
|
||||
$sql .= " AND t.fournisseur IN (1)";
|
||||
}
|
||||
|
||||
// Select thirdparties of given category
|
||||
if ($category > 0) {
|
||||
if (!empty($mode) && $mode != 4) { $sql .= " AND c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid"; }
|
||||
elseif (!empty($mode) && $mode == 4) { $sql .= " AND cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid"; }
|
||||
else { $sql .= " AND ((c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid) OR (cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid))"; }
|
||||
if (!empty($mode) && $mode != 4) {
|
||||
$sql .= " AND c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid";
|
||||
} elseif (!empty($mode) && $mode == 4) {
|
||||
$sql .= " AND cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid";
|
||||
} else {
|
||||
$sql .= " AND ((c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid) OR (cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid))";
|
||||
}
|
||||
}
|
||||
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc";
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
|
||||
$sql .= " AND t.rowid = sc.fk_soc";
|
||||
}
|
||||
//if ($email != NULL) $sql.= " AND s.email = \"".$email."\"";
|
||||
if ($socids) $sql .= " AND t.rowid IN (".$socids.")";
|
||||
if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||
if ($socids) {
|
||||
$sql .= " AND t.rowid IN (".$socids.")";
|
||||
}
|
||||
if ($search_sale > 0) {
|
||||
$sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||
}
|
||||
// Insert sale filter
|
||||
if ($search_sale > 0)
|
||||
{
|
||||
if ($search_sale > 0) {
|
||||
$sql .= " AND sc.fk_user = ".$search_sale;
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -195,13 +217,11 @@ class Thirdparties extends DolibarrApi
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
$i = 0;
|
||||
while ($i < $min)
|
||||
{
|
||||
while ($i < $min) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$soc_static = new Societe($this->db);
|
||||
if ($soc_static->fetch($obj->rowid)) {
|
||||
@ -235,8 +255,9 @@ class Thirdparties extends DolibarrApi
|
||||
foreach ($request_data as $field => $value) {
|
||||
$this->company->$field = $value;
|
||||
}
|
||||
if ($this->company->create(DolibarrApiAccess::$user) < 0)
|
||||
if ($this->company->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error creating thirdparty', array_merge(array($this->company->error), $this->company->errors));
|
||||
}
|
||||
|
||||
return $this->company->id;
|
||||
}
|
||||
@ -264,7 +285,9 @@ class Thirdparties extends DolibarrApi
|
||||
}
|
||||
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
if ($field == 'id') {
|
||||
continue;
|
||||
}
|
||||
$this->company->$field = $value;
|
||||
}
|
||||
|
||||
@ -295,8 +318,7 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$error = 0;
|
||||
|
||||
if ($id == $idtodelete)
|
||||
{
|
||||
if ($id == $idtodelete) {
|
||||
throw new RestException(400, 'Try to merge a thirdparty into itself');
|
||||
}
|
||||
|
||||
@ -345,26 +367,26 @@ class Thirdparties extends DolibarrApi
|
||||
'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur',
|
||||
'model_pdf', 'fk_projet'
|
||||
);
|
||||
foreach ($listofproperties as $property)
|
||||
{
|
||||
if (empty($object->$property)) $object->$property = $soc_origin->$property;
|
||||
foreach ($listofproperties as $property) {
|
||||
if (empty($object->$property)) {
|
||||
$object->$property = $soc_origin->$property;
|
||||
}
|
||||
}
|
||||
|
||||
// Concat some data
|
||||
$listofproperties = array(
|
||||
'note_public', 'note_private'
|
||||
);
|
||||
foreach ($listofproperties as $property)
|
||||
{
|
||||
foreach ($listofproperties as $property) {
|
||||
$object->$property = dol_concatdesc($object->$property, $soc_origin->$property);
|
||||
}
|
||||
|
||||
// Merge extrafields
|
||||
if (is_array($soc_origin->array_options))
|
||||
{
|
||||
foreach ($soc_origin->array_options as $key => $val)
|
||||
{
|
||||
if (empty($object->array_options[$key])) $object->array_options[$key] = $val;
|
||||
if (is_array($soc_origin->array_options)) {
|
||||
foreach ($soc_origin->array_options as $key => $val) {
|
||||
if (empty($object->array_options[$key])) {
|
||||
$object->array_options[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -378,8 +400,7 @@ class Thirdparties extends DolibarrApi
|
||||
// If thirdparty has a new code that is same than origin, we clean origin code to avoid duplicate key from database unique keys.
|
||||
if ($soc_origin->code_client == $object->code_client
|
||||
|| $soc_origin->code_fournisseur == $object->code_fournisseur
|
||||
|| $soc_origin->barcode == $object->barcode)
|
||||
{
|
||||
|| $soc_origin->barcode == $object->barcode) {
|
||||
dol_syslog("We clean customer and supplier code so we will be able to make the update of target");
|
||||
$soc_origin->code_client = '';
|
||||
$soc_origin->code_fournisseur = '';
|
||||
@ -389,8 +410,7 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
// Update
|
||||
$result = $object->update($object->id, $user, 0, 1, 1, 'merge');
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -425,8 +445,7 @@ class Thirdparties extends DolibarrApi
|
||||
);
|
||||
|
||||
//First, all core objects must update their tables
|
||||
foreach ($objects as $object_name => $object_file)
|
||||
{
|
||||
foreach ($objects as $object_name => $object_file) {
|
||||
require_once DOL_DOCUMENT_ROOT.$object_file;
|
||||
|
||||
if (!$error && !$object_name::replaceThirdparty($this->db, $soc_origin->id, $object->id)) {
|
||||
@ -584,8 +603,7 @@ class Thirdparties extends DolibarrApi
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
@ -593,13 +611,11 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$result = $categories->getListForItem($id, 'customer', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (is_numeric($result) && $result < 0)
|
||||
{
|
||||
if (is_numeric($result) && $result < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
|
||||
}
|
||||
|
||||
if (is_numeric($result) && $result == 0) // To fix a return of 0 instead of empty array of method getListForItem
|
||||
{
|
||||
if (is_numeric($result) && $result == 0) { // To fix a return of 0 instead of empty array of method getListForItem
|
||||
return array();
|
||||
}
|
||||
|
||||
@ -702,8 +718,7 @@ class Thirdparties extends DolibarrApi
|
||||
}
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
@ -711,13 +726,11 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$result = $categories->getListForItem($id, 'supplier', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (is_numeric($result) && $result < 0)
|
||||
{
|
||||
if (is_numeric($result) && $result < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
|
||||
}
|
||||
|
||||
if (is_numeric($result) && $result == 0) // To fix a return of 0 instead of empty array of method getListForItem
|
||||
{
|
||||
if (is_numeric($result) && $result == 0) { // To fix a return of 0 instead of empty array of method getListForItem
|
||||
return array();
|
||||
}
|
||||
|
||||
@ -1005,8 +1018,12 @@ class Thirdparties extends DolibarrApi
|
||||
$sql = "SELECT f.ref, f.type as factype, re.fk_facture_source, re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc, re.description, re.fk_facture, re.fk_facture_line";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " WHERE f.rowid = re.fk_facture_source AND re.fk_soc = ".$id;
|
||||
if ($filter == "available") $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL";
|
||||
if ($filter == "used") $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)";
|
||||
if ($filter == "available") {
|
||||
$sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL";
|
||||
}
|
||||
if ($filter == "used") {
|
||||
$sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)";
|
||||
}
|
||||
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
@ -1137,7 +1154,9 @@ class Thirdparties extends DolibarrApi
|
||||
$sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
|
||||
$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
if ($id) $sql .= " WHERE fk_soc = ".$id." ";
|
||||
if ($id) {
|
||||
$sql .= " WHERE fk_soc = ".$id." ";
|
||||
}
|
||||
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
@ -1150,11 +1169,9 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$accounts = array();
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$account = new CompanyBankAccount($this->db);
|
||||
if ($account->fetch($obj->rowid)) {
|
||||
@ -1209,8 +1226,9 @@ class Thirdparties extends DolibarrApi
|
||||
$account->$field = $value;
|
||||
}
|
||||
|
||||
if ($account->create(DolibarrApiAccess::$user) < 0)
|
||||
if ($account->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error creating Company Bank account');
|
||||
}
|
||||
|
||||
if (empty($account->rum)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
|
||||
@ -1219,8 +1237,9 @@ class Thirdparties extends DolibarrApi
|
||||
$account->date_rum = dol_now();
|
||||
}
|
||||
|
||||
if ($account->update(DolibarrApiAccess::$user) < 0)
|
||||
if ($account->update(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error updating values');
|
||||
}
|
||||
|
||||
return $this->_cleanObjectDatas($account);
|
||||
}
|
||||
@ -1264,8 +1283,9 @@ class Thirdparties extends DolibarrApi
|
||||
$account->date_rum = dol_now();
|
||||
}
|
||||
|
||||
if ($account->update(DolibarrApiAccess::$user) < 0)
|
||||
if ($account->update(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error updating values');
|
||||
}
|
||||
|
||||
return $this->_cleanObjectDatas($account);
|
||||
}
|
||||
@ -1290,8 +1310,9 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$account->fetch($bankaccount_id);
|
||||
|
||||
if (!$account->socid == $id)
|
||||
if (!$account->socid == $id) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
return $account->delete(DolibarrApiAccess::$user);
|
||||
}
|
||||
@ -1342,8 +1363,12 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$sql = "SELECT rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
if ($id) $sql .= " WHERE fk_soc = ".$id." ";
|
||||
if ($companybankid) $sql .= " AND rowid = ".$companybankid."";
|
||||
if ($id) {
|
||||
$sql .= " WHERE fk_soc = ".$id." ";
|
||||
}
|
||||
if ($companybankid) {
|
||||
$sql .= " AND rowid = ".$companybankid."";
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$accounts = array();
|
||||
@ -1409,7 +1434,9 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
$sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account";
|
||||
$sql .= " WHERE fk_soc = $id";
|
||||
if ($site) $sql .= " AND site ='$site'";
|
||||
if ($site) {
|
||||
$sql .= " AND site ='$site'";
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
@ -1422,8 +1449,7 @@ class Thirdparties extends DolibarrApi
|
||||
$accounts = array();
|
||||
|
||||
$num = $this->db->num_rows($result);
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$account = new SocieteAccount($this->db);
|
||||
|
||||
@ -1493,8 +1519,9 @@ class Thirdparties extends DolibarrApi
|
||||
$account->$field = $value;
|
||||
}
|
||||
|
||||
if ($account->create(DolibarrApiAccess::$user) < 0)
|
||||
if ($account->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error creating SocieteAccount entity. Ensure that the ID of thirdparty provided does exist!');
|
||||
}
|
||||
|
||||
$this->_cleanObjectDatas($account);
|
||||
|
||||
@ -1582,8 +1609,9 @@ class Thirdparties extends DolibarrApi
|
||||
$account->$field = $value;
|
||||
}
|
||||
|
||||
if ($account->update(DolibarrApiAccess::$user) < 0)
|
||||
if ($account->update(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error updating SocieteAccount entity.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->_cleanObjectDatas($account);
|
||||
@ -1624,8 +1652,9 @@ class Thirdparties extends DolibarrApi
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' ";
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result && $this->db->num_rows($result) !== 0)
|
||||
if ($result && $this->db->num_rows($result) !== 0) {
|
||||
throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key.");
|
||||
}
|
||||
}
|
||||
|
||||
$obj = $this->db->fetch_object($result);
|
||||
@ -1636,8 +1665,9 @@ class Thirdparties extends DolibarrApi
|
||||
$account->$field = $value;
|
||||
}
|
||||
|
||||
if ($account->update(DolibarrApiAccess::$user) < 0)
|
||||
if ($account->update(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error updating SocieteAccount account');
|
||||
}
|
||||
|
||||
$this->_cleanObjectDatas($account);
|
||||
|
||||
@ -1713,8 +1743,7 @@ class Thirdparties extends DolibarrApi
|
||||
$i = 0;
|
||||
|
||||
$num = $this->db->num_rows($result);
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$account = new SocieteAccount($this->db);
|
||||
$account->fetch($obj->rowid);
|
||||
@ -1781,8 +1810,9 @@ class Thirdparties extends DolibarrApi
|
||||
{
|
||||
$thirdparty = array();
|
||||
foreach (Thirdparties::$FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
if (!isset($data[$field])) {
|
||||
throw new RestException(400, "$field field missing");
|
||||
}
|
||||
$thirdparty[$field] = $data[$field];
|
||||
}
|
||||
return $thirdparty;
|
||||
|
||||
@ -64,8 +64,7 @@ class Client extends Societe
|
||||
|
||||
$sql = "SELECT count(s.rowid) as nb, s.client";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$user->socid)
|
||||
{
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
|
||||
$sql .= " WHERE sc.fk_user = ".$user->id;
|
||||
$clause = "AND";
|
||||
@ -75,12 +74,14 @@ class Client extends Societe
|
||||
$sql .= " GROUP BY s.client";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
if ($obj->client == 1 || $obj->client == 3) $this->nb["customers"] += $obj->nb;
|
||||
if ($obj->client == 2 || $obj->client == 3) $this->nb["prospects"] += $obj->nb;
|
||||
if ($resql) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
if ($obj->client == 1 || $obj->client == 3) {
|
||||
$this->nb["customers"] += $obj->nb;
|
||||
}
|
||||
if ($obj->client == 2 || $obj->client == 3) {
|
||||
$this->nb["prospects"] += $obj->nb;
|
||||
}
|
||||
}
|
||||
$this->db->free($resql);
|
||||
return 1;
|
||||
@ -101,8 +102,10 @@ class Client extends Societe
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm";
|
||||
if ($active >= 0) $sql .= " WHERE active = ".$active;
|
||||
$sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm";
|
||||
if ($active >= 0) {
|
||||
$sql .= " WHERE active = ".$active;
|
||||
}
|
||||
$resql = $this->db->query($sql);
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
@ -84,32 +84,33 @@ class CompanyBankAccount extends Account
|
||||
$error = 0;
|
||||
// Correct default_rib to be sure to have always one default
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'";
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$numrows = $this->db->num_rows($result);
|
||||
if ($this->default_rib && $numrows > 0) $this->default_rib = 0;
|
||||
if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1;
|
||||
if ($this->default_rib && $numrows > 0) {
|
||||
$this->default_rib = 0;
|
||||
}
|
||||
if (empty($this->default_rib) && $numrows == 0) {
|
||||
$this->default_rib = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
|
||||
$sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->affected_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->affected_rows($resql)) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib");
|
||||
|
||||
if (!$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('COMPANY_RIB_CREATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
@ -136,10 +137,16 @@ class CompanyBankAccount extends Account
|
||||
global $conf;
|
||||
$error = 0;
|
||||
|
||||
if (!$this->id) return -1;
|
||||
if (!$this->id) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
|
||||
if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
|
||||
if (dol_strlen($this->domiciliation) > 255) {
|
||||
$this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
|
||||
}
|
||||
if (dol_strlen($this->owner_address) > 255) {
|
||||
$this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
|
||||
$sql .= " bank = '".$this->db->escape($this->bank)."'";
|
||||
@ -153,28 +160,28 @@ class CompanyBankAccount extends Account
|
||||
$sql .= ",proprio = '".$this->db->escape($this->proprio)."'";
|
||||
$sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'";
|
||||
$sql .= ",default_rib = ".$this->default_rib;
|
||||
if ($conf->prelevement->enabled)
|
||||
{
|
||||
if ($conf->prelevement->enabled) {
|
||||
$sql .= ",frstrecur = '".$this->db->escape($this->frstrecur)."'";
|
||||
$sql .= ",rum = '".$this->db->escape($this->rum)."'";
|
||||
$sql .= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null");
|
||||
}
|
||||
if (trim($this->label) != '')
|
||||
if (trim($this->label) != '') {
|
||||
$sql .= ",label = '".$this->db->escape($this->label)."'";
|
||||
else $sql .= ",label = NULL";
|
||||
} else {
|
||||
$sql .= ",label = NULL";
|
||||
}
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if (!$notrigger)
|
||||
{
|
||||
if ($result) {
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('COMPANY_RIB_MODIFY', $user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
@ -199,24 +206,29 @@ class CompanyBankAccount extends Account
|
||||
*/
|
||||
public function fetch($id, $socid = 0, $default = 1, $type = 'ban')
|
||||
{
|
||||
if (empty($id) && empty($socid)) return -1;
|
||||
if (empty($id) && empty($socid)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
|
||||
$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
if ($id) $sql .= " WHERE rowid = ".$id;
|
||||
if ($socid)
|
||||
{
|
||||
if ($id) {
|
||||
$sql .= " WHERE rowid = ".$id;
|
||||
}
|
||||
if ($socid) {
|
||||
$sql .= " WHERE fk_soc = ".$socid;
|
||||
if ($default > -1) $sql .= " AND default_rib = ".$this->db->escape($default);
|
||||
if ($type) $sql .= " AND type ='".$this->db->escape($type)."'";
|
||||
if ($default > -1) {
|
||||
$sql .= " AND default_rib = ".$this->db->escape($default);
|
||||
}
|
||||
if ($type) {
|
||||
$sql .= " AND type ='".$this->db->escape($type)."'";
|
||||
}
|
||||
}
|
||||
|
||||
$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->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref
|
||||
@ -268,28 +280,26 @@ class CompanyBankAccount extends Account
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('COMPANY_RIB_DELETE', $user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
if (!$this->db->query($sql)) {
|
||||
$error++;
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
@ -332,10 +342,8 @@ class CompanyBankAccount extends Account
|
||||
|
||||
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
|
||||
$result1 = $this->db->query($sql1);
|
||||
if ($result1)
|
||||
{
|
||||
if ($this->db->num_rows($result1) == 0)
|
||||
{
|
||||
if ($result1) {
|
||||
if ($this->db->num_rows($result1) == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
$obj = $this->db->fetch_object($result1);
|
||||
@ -352,8 +360,7 @@ class CompanyBankAccount extends Account
|
||||
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
|
||||
$result3 = $this->db->query($sql3);
|
||||
|
||||
if (!$result2 || !$result3)
|
||||
{
|
||||
if (!$result2 || !$result3) {
|
||||
dol_print_error($this->db);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
|
||||
@ -232,8 +232,12 @@ class CompanyPaymentMode 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -313,8 +317,12 @@ class CompanyPaymentMode extends CommonObject
|
||||
*/
|
||||
public function fetch($id, $ref = null, $socid = 0, $type = '', $morewhere = '')
|
||||
{
|
||||
if ($socid) $morewhere .= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1";
|
||||
if ($type) $morewhere .= " AND type = '".$this->db->escape($type)."'";
|
||||
if ($socid) {
|
||||
$morewhere .= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1";
|
||||
}
|
||||
if ($type) {
|
||||
$morewhere .= " AND type = '".$this->db->escape($type)."'";
|
||||
}
|
||||
|
||||
$result = $this->fetchCommon($id, $ref, $morewhere);
|
||||
//if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
|
||||
@ -375,7 +383,9 @@ class CompanyPaymentMode extends CommonObject
|
||||
global $dolibarr_main_authentication, $dolibarr_main_demo;
|
||||
global $menumanager;
|
||||
|
||||
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 = '';
|
||||
$companylink = '';
|
||||
@ -386,33 +396,40 @@ class CompanyPaymentMode extends CommonObject
|
||||
|
||||
$url = dol_buildpath('/monmodule/companypaymentmode_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("ShowCompanyPaymentMode");
|
||||
$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.'>';
|
||||
$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;
|
||||
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
|
||||
|
||||
@ -433,33 +450,36 @@ class CompanyPaymentMode extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
|
||||
$result1 = $this->db->query($sql1);
|
||||
if ($result1)
|
||||
{
|
||||
if ($this->db->num_rows($result1) == 0)
|
||||
{
|
||||
if ($result1) {
|
||||
if ($this->db->num_rows($result1) == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
$obj = $this->db->fetch_object($result1);
|
||||
|
||||
$type = '';
|
||||
if (empty($alltypes)) $type = $obj->type;
|
||||
if (empty($alltypes)) {
|
||||
$type = $obj->type;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0, tms = tms";
|
||||
$sql2 .= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc;
|
||||
if ($type) $sql2 .= " AND type = '".$this->db->escape($type)."'";
|
||||
if ($type) {
|
||||
$sql2 .= " AND type = '".$this->db->escape($type)."'";
|
||||
}
|
||||
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
|
||||
$result2 = $this->db->query($sql2);
|
||||
|
||||
$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
|
||||
$sql3 .= " WHERE rowid = ".$obj->id;
|
||||
if ($type) $sql3 .= " AND type = '".$this->db->escape($type)."'";
|
||||
if ($type) {
|
||||
$sql3 .= " AND type = '".$this->db->escape($type)."'";
|
||||
}
|
||||
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
|
||||
$result3 = $this->db->query($sql3);
|
||||
|
||||
if (!$result2 || !$result3)
|
||||
{
|
||||
if (!$result2 || !$result3) {
|
||||
dol_print_error($this->db);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
@ -496,8 +516,7 @@ class CompanyPaymentMode 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("mymodule");
|
||||
$this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled');
|
||||
@ -507,7 +526,9 @@ class CompanyPaymentMode extends CommonObject
|
||||
}
|
||||
|
||||
$statusType = 'status5';
|
||||
if ($status == self::STATUS_ENABLED) $statusType = 'status4';
|
||||
if ($status == self::STATUS_ENABLED) {
|
||||
$statusType = 'status4';
|
||||
}
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
@ -525,28 +546,23 @@ class CompanyPaymentMode 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;
|
||||
|
||||
@ -905,9 +905,8 @@ class Societe extends CommonObject
|
||||
// Ajout du commercial affecte
|
||||
if ($this->commercial_id != '' && $this->commercial_id != -1) {
|
||||
$this->add_commercial($user, $this->commercial_id);
|
||||
}
|
||||
// si un commercial cree un client il lui est affecte automatiquement
|
||||
elseif (empty($user->rights->societe->client->voir)) {
|
||||
} elseif (empty($user->rights->societe->client->voir)) {
|
||||
// si un commercial cree un client il lui est affecte automatiquement
|
||||
$this->add_commercial($user, $user->id);
|
||||
}
|
||||
|
||||
@ -2626,20 +2625,17 @@ class Societe extends CommonObject
|
||||
|
||||
$s = '';
|
||||
if (empty($option) || preg_match('/prospect/', $option)) {
|
||||
if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
|
||||
{
|
||||
if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
|
||||
$s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
|
||||
}
|
||||
}
|
||||
if (empty($option) || preg_match('/customer/', $option)) {
|
||||
if (($this->client == 1 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
|
||||
{
|
||||
if (($this->client == 1 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
|
||||
$s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
|
||||
}
|
||||
}
|
||||
if (empty($option) || preg_match('/supplier/', $option)) {
|
||||
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $this->fournisseur)
|
||||
{
|
||||
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $this->fournisseur) {
|
||||
$s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
|
||||
}
|
||||
}
|
||||
@ -3811,8 +3807,7 @@ class Societe extends CommonObject
|
||||
|
||||
dol_syslog("We ask to create a contact/address too", LOG_DEBUG);
|
||||
$result = $this->create_individual($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($this->error, $this->errors, 'errors');
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
@ -4682,8 +4677,7 @@ class Societe extends CommonObject
|
||||
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
|
||||
@ -172,7 +172,9 @@ class SocieteAccount extends CommonObject
|
||||
|
||||
$this->db = $db;
|
||||
|
||||
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0;
|
||||
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
|
||||
$this->fields['rowid']['visible'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -248,7 +250,9 @@ class SocieteAccount 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;
|
||||
}
|
||||
|
||||
@ -375,7 +379,9 @@ class SocieteAccount extends CommonObject
|
||||
global $dolibarr_main_authentication, $dolibarr_main_demo;
|
||||
global $menumanager;
|
||||
|
||||
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 = '';
|
||||
|
||||
@ -388,33 +394,40 @@ class SocieteAccount extends CommonObject
|
||||
|
||||
$url = dol_buildpath('/website/websiteaccount_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("WebsiteAccount");
|
||||
$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.'>';
|
||||
$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;
|
||||
@ -444,35 +457,49 @@ class SocieteAccount extends CommonObject
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
|
||||
if ($mode == 0)
|
||||
{
|
||||
if ($mode == 0) {
|
||||
$prefix = '';
|
||||
if ($status == 1) return $langs->trans('Enabled');
|
||||
elseif ($status == 0) return $langs->trans('Disabled');
|
||||
} elseif ($mode == 1)
|
||||
{
|
||||
if ($status == 1) return $langs->trans('Enabled');
|
||||
elseif ($status == 0) return $langs->trans('Disabled');
|
||||
} elseif ($mode == 2)
|
||||
{
|
||||
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
|
||||
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
|
||||
} elseif ($mode == 3)
|
||||
{
|
||||
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
|
||||
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
|
||||
} elseif ($mode == 4)
|
||||
{
|
||||
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
|
||||
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
|
||||
} elseif ($mode == 5)
|
||||
{
|
||||
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
|
||||
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
|
||||
} elseif ($mode == 6)
|
||||
{
|
||||
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
|
||||
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
|
||||
if ($status == 1) {
|
||||
return $langs->trans('Enabled');
|
||||
} elseif ($status == 0) {
|
||||
return $langs->trans('Disabled');
|
||||
}
|
||||
} elseif ($mode == 1) {
|
||||
if ($status == 1) {
|
||||
return $langs->trans('Enabled');
|
||||
} elseif ($status == 0) {
|
||||
return $langs->trans('Disabled');
|
||||
}
|
||||
} elseif ($mode == 2) {
|
||||
if ($status == 1) {
|
||||
return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
|
||||
} elseif ($status == 0) {
|
||||
return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
|
||||
}
|
||||
} elseif ($mode == 3) {
|
||||
if ($status == 1) {
|
||||
return img_picto($langs->trans('Enabled'), 'statut4');
|
||||
} elseif ($status == 0) {
|
||||
return img_picto($langs->trans('Disabled'), 'statut5');
|
||||
}
|
||||
} elseif ($mode == 4) {
|
||||
if ($status == 1) {
|
||||
return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
|
||||
} elseif ($status == 0) {
|
||||
return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
|
||||
}
|
||||
} elseif ($mode == 5) {
|
||||
if ($status == 1) {
|
||||
return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
|
||||
} elseif ($status == 0) {
|
||||
return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
|
||||
}
|
||||
} elseif ($mode == 6) {
|
||||
if ($status == 1) {
|
||||
return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
|
||||
} elseif ($status == 0) {
|
||||
return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -489,28 +516,23 @@ class SocieteAccount 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;
|
||||
|
||||
@ -35,22 +35,32 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thi
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST('socid', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'societe', $socid, '&societe');
|
||||
$object = new Societe($db);
|
||||
if ($socid > 0) $object->fetch($socid);
|
||||
if ($socid > 0) {
|
||||
$object->fetch($socid);
|
||||
}
|
||||
|
||||
// Sort & Order fields
|
||||
$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 (!$sortorder) $sortorder = 'DESC';
|
||||
if (!$sortfield) $sortfield = 'dateprint';
|
||||
if (!$sortorder) {
|
||||
$sortorder = 'DESC';
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = 'dateprint';
|
||||
}
|
||||
|
||||
// Search fields
|
||||
$sref = GETPOST("sref");
|
||||
@ -59,8 +69,7 @@ $month = GETPOST('month', 'int');
|
||||
$year = GETPOST('year', 'int');
|
||||
|
||||
// Clean up 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
|
||||
$sref = '';
|
||||
$sprod_fulldescr = '';
|
||||
$year = '';
|
||||
@ -83,7 +92,9 @@ $hookmanager->initHooks(array('consumptionthirdparty'));
|
||||
|
||||
$parameters = array('id'=>$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');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -96,12 +107,13 @@ $formother = new FormOther($db);
|
||||
$productstatic = new Product($db);
|
||||
|
||||
$title = $langs->trans("Referers", $object->name);
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title;
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
|
||||
$title = $object->name." - ".$title;
|
||||
}
|
||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if (empty($socid))
|
||||
{
|
||||
if (empty($socid)) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
@ -118,15 +130,13 @@ print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
||||
{
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
|
||||
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
||||
}
|
||||
|
||||
//if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events');
|
||||
|
||||
if ($object->client)
|
||||
{
|
||||
if ($object->client) {
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
|
||||
@ -137,21 +147,32 @@ if ($object->client)
|
||||
print '</td></tr>';
|
||||
$sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid;
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) dol_print_error($db);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$obj = $db->fetch_object($resql);
|
||||
$nbFactsClient = $obj->nb;
|
||||
$thirdTypeArray['customer'] = $langs->trans("customer");
|
||||
if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
|
||||
if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders');
|
||||
if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices');
|
||||
if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts');
|
||||
if ($conf->propal->enabled && $user->rights->propal->lire) {
|
||||
$elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
|
||||
}
|
||||
if ($conf->commande->enabled && $user->rights->commande->lire) {
|
||||
$elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders');
|
||||
}
|
||||
if ($conf->facture->enabled && $user->rights->facture->lire) {
|
||||
$elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices');
|
||||
}
|
||||
if ($conf->contrat->enabled && $user->rights->contrat->lire) {
|
||||
$elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts');
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($conf->ficheinter->enabled) && !empty($user->rights->ficheinter->lire)) $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
|
||||
if (!empty($conf->ficheinter->enabled) && !empty($user->rights->ficheinter->lire)) {
|
||||
$elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
|
||||
}
|
||||
|
||||
if ($object->fournisseur)
|
||||
{
|
||||
if ($object->fournisseur) {
|
||||
$langs->load("supplier_proposal");
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
||||
@ -163,14 +184,22 @@ if ($object->fournisseur)
|
||||
print '</td></tr>';
|
||||
$sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".$socid;
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) dol_print_error($db);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$obj = $db->fetch_object($resql);
|
||||
$nbCmdsFourn = $obj->nb;
|
||||
$thirdTypeArray['supplier'] = $langs->trans("supplier");
|
||||
if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
|
||||
if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
|
||||
if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal'] = $langs->transnoentitiesnoconv('SupplierProposals');
|
||||
if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) {
|
||||
$elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
|
||||
}
|
||||
if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) {
|
||||
$elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
|
||||
}
|
||||
if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) {
|
||||
$elementTypeArray['supplier_proposal'] = $langs->transnoentitiesnoconv('SupplierProposals');
|
||||
}
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
@ -194,8 +223,7 @@ $sql_select = '';
|
||||
$dateprint = 'f.datep';
|
||||
$doc_number='f.id';
|
||||
}*/
|
||||
if ($type_element == 'fichinter')
|
||||
{ // Customer : show products from invoices
|
||||
if ($type_element == 'fichinter') { // Customer : show products from invoices
|
||||
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
|
||||
$documentstatic = new Fichinter($db);
|
||||
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, ';
|
||||
@ -205,8 +233,7 @@ if ($type_element == 'fichinter')
|
||||
$dateprint = 'f.datec';
|
||||
$doc_number = 'f.ref';
|
||||
}
|
||||
if ($type_element == 'invoice')
|
||||
{ // Customer : show products from invoices
|
||||
if ($type_element == 'invoice') { // Customer : show products from invoices
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$documentstatic = new Facture($db);
|
||||
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, ';
|
||||
@ -218,8 +245,7 @@ if ($type_element == 'invoice')
|
||||
$doc_number = 'f.ref';
|
||||
$thirdTypeSelect = 'customer';
|
||||
}
|
||||
if ($type_element == 'propal')
|
||||
{
|
||||
if ($type_element == 'propal') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
$documentstatic = new Propal($db);
|
||||
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, ';
|
||||
@ -231,8 +257,7 @@ if ($type_element == 'propal')
|
||||
$doc_number = 'c.ref';
|
||||
$thirdTypeSelect = 'customer';
|
||||
}
|
||||
if ($type_element == 'order')
|
||||
{
|
||||
if ($type_element == 'order') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
$documentstatic = new Commande($db);
|
||||
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, ';
|
||||
@ -244,8 +269,7 @@ if ($type_element == 'order')
|
||||
$doc_number = 'c.ref';
|
||||
$thirdTypeSelect = 'customer';
|
||||
}
|
||||
if ($type_element == 'supplier_invoice')
|
||||
{ // Supplier : Show products from invoices.
|
||||
if ($type_element == 'supplier_invoice') { // Supplier : Show products from invoices.
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
$documentstatic = new FactureFournisseur($db);
|
||||
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, ';
|
||||
@ -257,8 +281,7 @@ if ($type_element == 'supplier_invoice')
|
||||
$doc_number = 'f.ref';
|
||||
$thirdTypeSelect = 'supplier';
|
||||
}
|
||||
if ($type_element == 'supplier_proposal')
|
||||
{
|
||||
if ($type_element == 'supplier_proposal') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
|
||||
$documentstatic = new SupplierProposal($db);
|
||||
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, ';
|
||||
@ -270,8 +293,7 @@ if ($type_element == 'supplier_proposal')
|
||||
$doc_number = 'c.ref';
|
||||
$thirdTypeSelect = 'supplier';
|
||||
}
|
||||
if ($type_element == 'supplier_order')
|
||||
{ // Supplier : Show products from orders.
|
||||
if ($type_element == 'supplier_order') { // Supplier : Show products from orders.
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
||||
$documentstatic = new CommandeFournisseur($db);
|
||||
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, ';
|
||||
@ -283,8 +305,7 @@ if ($type_element == 'supplier_order')
|
||||
$doc_number = 'c.ref';
|
||||
$thirdTypeSelect = 'supplier';
|
||||
}
|
||||
if ($type_element == 'contract')
|
||||
{ // Order
|
||||
if ($type_element == 'contract') { // Order
|
||||
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
||||
$documentstatic = new Contrat($db);
|
||||
$documentstaticline = new ContratLigne($db);
|
||||
@ -301,26 +322,42 @@ if ($type_element == 'contract')
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
|
||||
|
||||
if (!empty($sql_select))
|
||||
{
|
||||
if (!empty($sql_select)) {
|
||||
$sql = $sql_select;
|
||||
$sql .= ' d.description as description,';
|
||||
if ($type_element != 'fichinter' && $type_element != 'contract' && $type_element != 'supplier_proposal') $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
|
||||
if ($type_element == 'supplier_proposal') $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
|
||||
if ($type_element == 'contract') $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
|
||||
if ($type_element != 'fichinter') $sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity,';
|
||||
if ($type_element != 'fichinter' && $type_element != 'contract' && $type_element != 'supplier_proposal') {
|
||||
$sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
|
||||
}
|
||||
if ($type_element == 'supplier_proposal') {
|
||||
$sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
|
||||
}
|
||||
if ($type_element == 'contract') {
|
||||
$sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
|
||||
}
|
||||
if ($type_element != 'fichinter') {
|
||||
$sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity,';
|
||||
}
|
||||
$sql .= " s.rowid as socid ";
|
||||
if ($type_element != 'fichinter') $sql .= ", p.ref as prod_ref, p.label as product_label";
|
||||
if ($type_element != 'fichinter') {
|
||||
$sql .= ", p.ref as prod_ref, p.label as product_label";
|
||||
}
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from;
|
||||
if ($type_element != 'fichinter') $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid ';
|
||||
if ($type_element != 'fichinter') {
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid ';
|
||||
}
|
||||
$sql .= $where;
|
||||
$sql .= dolSqlDateFilter($dateprint, 0, $month, $year);
|
||||
if ($sref) $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'";
|
||||
if ($sprod_fulldescr)
|
||||
{
|
||||
if ($sref) {
|
||||
$sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'";
|
||||
}
|
||||
if ($sprod_fulldescr) {
|
||||
$sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'";
|
||||
if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'";
|
||||
if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'";
|
||||
if (GETPOST('type_element') != 'fichinter') {
|
||||
$sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'";
|
||||
}
|
||||
if (GETPOST('type_element') != 'fichinter') {
|
||||
$sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'";
|
||||
}
|
||||
$sql .= ")";
|
||||
}
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
@ -334,8 +371,7 @@ if (!empty($sql_select))
|
||||
|
||||
$disabled = 0;
|
||||
$showempty = 2;
|
||||
if (empty($elementTypeArray) && !$object->client && !$object->fournisseur)
|
||||
{
|
||||
if (empty($elementTypeArray) && !$object->client && !$object->fournisseur) {
|
||||
$showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef");
|
||||
$disabled = 1;
|
||||
}
|
||||
@ -354,21 +390,36 @@ $param .= "&type_element=".urlencode($type_element);
|
||||
|
||||
$total_qty = 0;
|
||||
|
||||
if ($sql_select)
|
||||
{
|
||||
if ($sql_select) {
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) dol_print_error($db);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($sprod_fulldescr) $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr);
|
||||
if ($sref) $param .= "&sref=".urlencode($sref);
|
||||
if ($month) $param .= "&month=".urlencode($month);
|
||||
if ($year) $param .= "&year=".urlencode($year);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
if ($sprod_fulldescr) {
|
||||
$param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr);
|
||||
}
|
||||
if ($sref) {
|
||||
$param .= "&sref=".urlencode($sref);
|
||||
}
|
||||
if ($month) {
|
||||
$param .= "&month=".urlencode($month);
|
||||
}
|
||||
if ($year) {
|
||||
$param .= "&year=".urlencode($year);
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
|
||||
print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit);
|
||||
|
||||
@ -412,8 +463,7 @@ if ($sql_select)
|
||||
|
||||
|
||||
$i = 0;
|
||||
while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit))
|
||||
{
|
||||
while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) {
|
||||
$documentstatic->id = $objp->doc_id;
|
||||
$documentstatic->ref = $objp->doc_number;
|
||||
$documentstatic->type = $objp->doc_type;
|
||||
@ -423,7 +473,9 @@ if ($sql_select)
|
||||
$documentstatic->status = $objp->status;
|
||||
$documentstatic->paye = $objp->paid;
|
||||
|
||||
if (is_object($documentstaticline)) $documentstaticline->statut = $objp->status;
|
||||
if (is_object($documentstaticline)) {
|
||||
$documentstaticline->statut = $objp->status;
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nobordernopadding nowrap" width="100">';
|
||||
@ -447,8 +499,7 @@ if ($sql_select)
|
||||
$text = ''; $description = ''; $type = 0;
|
||||
|
||||
// Code to show product duplicated from commonobject->printObjectLine
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
if ($objp->fk_product > 0) {
|
||||
$product_static = new Product($db);
|
||||
|
||||
$product_static->type = $objp->fk_product_type;
|
||||
@ -459,20 +510,21 @@ if ($sql_select)
|
||||
}
|
||||
|
||||
// Product
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
if ($objp->fk_product > 0) {
|
||||
// Define output language
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
|
||||
$prod = new Product($db);
|
||||
$prod->fetch($objp->fk_product);
|
||||
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
|
||||
if (empty($newlang)) $newlang = $object->default_lang;
|
||||
if (!empty($newlang))
|
||||
{
|
||||
if (empty($newlang) && GETPOST('lang_id', 'aZ09')) {
|
||||
$newlang = GETPOST('lang_id', 'aZ09');
|
||||
}
|
||||
if (empty($newlang)) {
|
||||
$newlang = $object->default_lang;
|
||||
}
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
@ -491,39 +543,40 @@ if ($sql_select)
|
||||
<?php
|
||||
$txt = '';
|
||||
print img_object($langs->trans("ShowReduc"), 'reduc').' ';
|
||||
if ($objp->description == '(DEPOSIT)') $txt = $langs->trans("Deposit");
|
||||
elseif ($objp->description == '(EXCESS RECEIVED)') $txt = $langs->trans("ExcessReceived");
|
||||
elseif ($objp->description == '(EXCESS PAID)') $txt = $langs->trans("ExcessPaid");
|
||||
if ($objp->description == '(DEPOSIT)') {
|
||||
$txt = $langs->trans("Deposit");
|
||||
} elseif ($objp->description == '(EXCESS RECEIVED)') {
|
||||
$txt = $langs->trans("ExcessReceived");
|
||||
} elseif ($objp->description == '(EXCESS PAID)') {
|
||||
$txt = $langs->trans("ExcessPaid");
|
||||
}
|
||||
//else $txt=$langs->trans("Discount");
|
||||
print $txt;
|
||||
?>
|
||||
</a>
|
||||
<?php
|
||||
if ($objp->description)
|
||||
{
|
||||
if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0)
|
||||
{
|
||||
if ($objp->description) {
|
||||
if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) {
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fetch($objp->fk_remise_except);
|
||||
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
|
||||
}
|
||||
if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0)
|
||||
{
|
||||
if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) {
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fetch($objp->fk_remise_except);
|
||||
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
|
||||
} elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0)
|
||||
{
|
||||
} elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) {
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fetch($objp->fk_remise_except);
|
||||
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));
|
||||
} elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0)
|
||||
{
|
||||
} elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) {
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fetch($objp->fk_remise_except);
|
||||
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
|
||||
// Add date of deposit
|
||||
if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')';
|
||||
if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
|
||||
echo ' ('.dol_print_date($discount->datec).')';
|
||||
}
|
||||
} else {
|
||||
echo ($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description);
|
||||
}
|
||||
@ -536,15 +589,16 @@ if ($sql_select)
|
||||
echo get_date_range($objp->date_start, $objp->date_end);
|
||||
|
||||
// Add description in form
|
||||
if (!empty($conf->global->PRODUIT_DESC_IN_FORM))
|
||||
{
|
||||
if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
|
||||
print (!empty($objp->description) && $objp->description != $objp->product_label) ? '<br>'.dol_htmlentitiesbr($objp->description) : '';
|
||||
}
|
||||
} else {
|
||||
if (!empty($objp->label) || !empty($objp->description))
|
||||
{
|
||||
if ($type == 1) $text = img_object($langs->trans('Service'), 'service');
|
||||
else $text = img_object($langs->trans('Product'), 'product');
|
||||
if (!empty($objp->label) || !empty($objp->description)) {
|
||||
if ($type == 1) {
|
||||
$text = img_object($langs->trans('Service'), 'service');
|
||||
} else {
|
||||
$text = img_object($langs->trans('Product'), 'product');
|
||||
}
|
||||
|
||||
if (!empty($objp->label)) {
|
||||
$text .= ' <strong>'.$objp->label.'</strong>';
|
||||
@ -580,7 +634,9 @@ if ($sql_select)
|
||||
print '</td>';
|
||||
|
||||
//print '<td class="left">'.$prodreftxt.'</td>';
|
||||
if ($type_element == 'invoice' && $objp->doc_type == Facture::TYPE_CREDIT_NOTE) $objp->prod_qty = -($objp->prod_qty);
|
||||
if ($type_element == 'invoice' && $objp->doc_type == Facture::TYPE_CREDIT_NOTE) {
|
||||
$objp->prod_qty = -($objp->prod_qty);
|
||||
}
|
||||
print '<td class="right">'.$objp->prod_qty.'</td>';
|
||||
$total_qty += $objp->prod_qty;
|
||||
|
||||
@ -606,9 +662,7 @@ if ($sql_select)
|
||||
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
elseif (empty($type_element) || $type_element == -1)
|
||||
{
|
||||
} elseif (empty($type_element) || $type_element == -1) {
|
||||
print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', (!empty($num) ? $num : 0), '', '');
|
||||
|
||||
print '<table class="liste centpercent">'."\n";
|
||||
|
||||
@ -42,12 +42,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
if (!empty($conf->adherent->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
}
|
||||
|
||||
$langs->loadLangs(array("companies", "commercial", "bills", "banks", "users"));
|
||||
if (!empty($conf->categorie->enabled)) $langs->load("categories");
|
||||
if (!empty($conf->incoterm->enabled)) $langs->load("incoterm");
|
||||
if (!empty($conf->notification->enabled)) $langs->load("mails");
|
||||
if (!empty($conf->categorie->enabled)) {
|
||||
$langs->load("categories");
|
||||
}
|
||||
if (!empty($conf->incoterm->enabled)) {
|
||||
$langs->load("incoterm");
|
||||
}
|
||||
if (!empty($conf->notification->enabled)) {
|
||||
$langs->load("mails");
|
||||
}
|
||||
|
||||
$mesg = ''; $error = 0; $errors = array();
|
||||
|
||||
@ -56,8 +64,12 @@ $cancel = GETPOST('cancel', 'alpha');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
$confirm = GETPOST('confirm');
|
||||
$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if (empty($socid) && $action == 'view') $action = 'create';
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
if (empty($socid) && $action == 'view') {
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
$object = new Societe($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
@ -68,8 +80,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('thirdpartycontact', 'globalcard'));
|
||||
|
||||
if ($object->fetch($socid) <= 0 && $action == 'view')
|
||||
{
|
||||
if ($object->fetch($socid) <= 0 && $action == 'view') {
|
||||
$langs->load("errors");
|
||||
print($langs->trans('ErrorRecordNotFound'));
|
||||
exit;
|
||||
@ -78,8 +89,7 @@ if ($object->fetch($socid) <= 0 && $action == 'view')
|
||||
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
|
||||
$canvas = $object->canvas ? $object->canvas : GETPOST("canvas");
|
||||
$objcanvas = null;
|
||||
if (!empty($canvas))
|
||||
{
|
||||
if (!empty($canvas)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
|
||||
$objcanvas = new Canvas($db, $action);
|
||||
$objcanvas->getCanvas('thirdparty', 'card', $canvas);
|
||||
@ -87,7 +97,9 @@ if (!empty($canvas))
|
||||
|
||||
// Security check
|
||||
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0);
|
||||
if (empty($user->rights->societe->contact->lire)) accessforbidden();
|
||||
if (empty($user->rights->societe->contact->lire)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -96,15 +108,14 @@ if (empty($user->rights->societe->contact->lire)) accessforbidden();
|
||||
|
||||
$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas);
|
||||
$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($reshook)) {
|
||||
if ($cancel) {
|
||||
$action = '';
|
||||
if (!empty($backtopage))
|
||||
{
|
||||
if (!empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
@ -124,21 +135,26 @@ $formfile = new FormFile($db);
|
||||
$formadmin = new FormAdmin($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
if ($socid > 0 && empty($object->id))
|
||||
{
|
||||
if ($socid > 0 && empty($object->id)) {
|
||||
$result = $object->fetch($socid);
|
||||
if ($result <= 0) dol_print_error('', $object->error);
|
||||
if ($result <= 0) {
|
||||
dol_print_error('', $object->error);
|
||||
}
|
||||
}
|
||||
|
||||
$title = $langs->trans("ThirdParty");
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$langs->trans('Card');
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
|
||||
$title = $object->name." - ".$langs->trans('Card');
|
||||
}
|
||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||
|
||||
|
||||
if (!empty($object->id)) $res = $object->fetch_optionals();
|
||||
if (!empty($object->id)) {
|
||||
$res = $object->fetch_optionals();
|
||||
}
|
||||
//if ($res < 0) { dol_print_error($db); exit; }
|
||||
|
||||
|
||||
@ -154,11 +170,9 @@ print dol_get_fiche_end();
|
||||
|
||||
print '<br>';
|
||||
|
||||
if ($action != 'presend')
|
||||
{
|
||||
if ($action != 'presend') {
|
||||
// Contacts list
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
|
||||
$result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,8 +40,7 @@ $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'))
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0)
|
||||
{
|
||||
if ($user->socid > 0) {
|
||||
unset($action);
|
||||
$socid = $user->socid;
|
||||
}
|
||||
@ -52,20 +51,29 @@ $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 (!empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield = $conf->global->MAIN_DOC_SORT_FIELD; }
|
||||
if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; }
|
||||
if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) {
|
||||
$sortfield = $conf->global->MAIN_DOC_SORT_FIELD;
|
||||
}
|
||||
if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) {
|
||||
$sortorder = $conf->global->MAIN_DOC_SORT_ORDER;
|
||||
}
|
||||
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) $sortfield = "position_name";
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "position_name";
|
||||
}
|
||||
|
||||
$object = new Societe($db);
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$result = $object->fetch($id, $ref);
|
||||
|
||||
$upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
|
||||
@ -91,16 +99,19 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans("ThirdParty").' - '.$langs->trans("Files");
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Files");
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
|
||||
$title = $object->name.' - '.$langs->trans("Files");
|
||||
}
|
||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if ($object->id)
|
||||
{
|
||||
if ($object->id) {
|
||||
/*
|
||||
* Show tabs
|
||||
*/
|
||||
if (!empty($conf->notification->enabled)) $langs->load("mails");
|
||||
if (!empty($conf->notification->enabled)) {
|
||||
$langs->load("mails");
|
||||
}
|
||||
$head = societe_prepare_head($object);
|
||||
|
||||
$form = new Form($db);
|
||||
@ -111,8 +122,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'];
|
||||
}
|
||||
|
||||
@ -126,13 +136,11 @@ if ($object->id)
|
||||
print '<table class="border tableforfield centpercent">';
|
||||
|
||||
// Prefix
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
||||
{
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
|
||||
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
||||
}
|
||||
|
||||
if ($object->client)
|
||||
{
|
||||
if ($object->client) {
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
|
||||
@ -143,8 +151,7 @@ if ($object->id)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ($object->fournisseur)
|
||||
{
|
||||
if ($object->fournisseur) {
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
|
||||
|
||||
@ -38,7 +38,9 @@ $hookmanager->initHooks(array('thirdpartiesindex'));
|
||||
$langs->load("companies");
|
||||
|
||||
$socid = GETPOST('socid', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
|
||||
// Security check
|
||||
$result = restrictedArea($user, 'societe', 0, '', '', '', '');
|
||||
@ -75,37 +77,62 @@ $total = 0;
|
||||
|
||||
$sql = "SELECT s.rowid, s.client, s.fournisseur";
|
||||
$sql .= " FROM ".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 s.entity IN ('.getEntity('societe').')';
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
if ($socid) $sql .= " AND s.rowid = ".$socid;
|
||||
if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
|
||||
if (!$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
if ($socid) {
|
||||
$sql .= " AND s.rowid = ".$socid;
|
||||
}
|
||||
if (!$user->rights->fournisseur->lire) {
|
||||
$sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
|
||||
}
|
||||
//print $sql;
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
while ($objp = $db->fetch_object($result))
|
||||
{
|
||||
if ($result) {
|
||||
while ($objp = $db->fetch_object($result)) {
|
||||
$found = 0;
|
||||
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found = 1; $third['prospect']++; }
|
||||
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third['customer']++; }
|
||||
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found = 1; $third['supplier']++; }
|
||||
if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found = 1; $third['other']++; }
|
||||
if ($found) $total++;
|
||||
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) {
|
||||
$found = 1; $third['prospect']++;
|
||||
}
|
||||
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) {
|
||||
$found = 1; $third['customer']++;
|
||||
}
|
||||
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) {
|
||||
$found = 1; $third['supplier']++;
|
||||
}
|
||||
if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) {
|
||||
$found = 1; $third['other']++;
|
||||
}
|
||||
if ($found) {
|
||||
$total++;
|
||||
}
|
||||
}
|
||||
} else dol_print_error($db);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder nohover centpercent">'."\n";
|
||||
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
|
||||
if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2))
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2)) {
|
||||
print '<tr><td class="center" colspan="2">';
|
||||
$dataseries = array();
|
||||
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[] = array($langs->trans("Prospects"), round($third['prospect']));
|
||||
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[] = array($langs->trans("Customers"), round($third['customer']));
|
||||
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[] = array($langs->trans("Suppliers"), round($third['supplier']));
|
||||
if (!empty($conf->societe->enabled)) $dataseries[] = array($langs->trans("Others"), round($third['other']));
|
||||
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
|
||||
$dataseries[] = array($langs->trans("Prospects"), round($third['prospect']));
|
||||
}
|
||||
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
|
||||
$dataseries[] = array($langs->trans("Customers"), round($third['customer']));
|
||||
}
|
||||
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) {
|
||||
$dataseries[] = array($langs->trans("Suppliers"), round($third['supplier']));
|
||||
}
|
||||
if (!empty($conf->societe->enabled)) {
|
||||
$dataseries[] = array($langs->trans("Others"), round($third['other']));
|
||||
}
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||
$dolgraph = new DolGraph();
|
||||
$dolgraph->SetData($dataseries);
|
||||
@ -117,20 +144,17 @@ if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) +
|
||||
print $dolgraph->show();
|
||||
print '</td></tr>'."\n";
|
||||
} else {
|
||||
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))
|
||||
{
|
||||
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
|
||||
$statstring = "<tr>";
|
||||
$statstring .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=p">'.$langs->trans("Prospects").'</a></td><td class="right">'.round($third['prospect']).'</td>';
|
||||
$statstring .= "</tr>";
|
||||
}
|
||||
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))
|
||||
{
|
||||
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
|
||||
$statstring .= "<tr>";
|
||||
$statstring .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=c">'.$langs->trans("Customers").'</a></td><td class="right">'.round($third['customer']).'</td>';
|
||||
$statstring .= "</tr>";
|
||||
}
|
||||
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire)
|
||||
{
|
||||
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire) {
|
||||
$statstring2 = "<tr>";
|
||||
$statstring2 .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td class="right">'.round($third['supplier']).'</td>';
|
||||
$statstring2 .= "</tr>";
|
||||
@ -144,8 +168,7 @@ print '</td></tr>';
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES))
|
||||
{
|
||||
if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
$elementtype = 'societe';
|
||||
|
||||
@ -159,26 +182,24 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
|
||||
$sql .= " WHERE c.type = 2";
|
||||
if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
|
||||
if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) {
|
||||
$sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
|
||||
}
|
||||
$sql .= " AND c.entity IN (".getEntity('category').")";
|
||||
$sql .= " GROUP BY c.label";
|
||||
$total = 0;
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
$dataseries = array();
|
||||
$rest = 0;
|
||||
$nbmax = 10;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
if ($i < $nbmax)
|
||||
{
|
||||
if ($i < $nbmax) {
|
||||
$dataseries[] = array($obj->label, round($obj->nb));
|
||||
} else {
|
||||
$rest += $obj->nb;
|
||||
@ -186,8 +207,7 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
|
||||
$total += $obj->nb;
|
||||
$i++;
|
||||
}
|
||||
if ($i > $nbmax)
|
||||
{
|
||||
if ($i > $nbmax) {
|
||||
$dataseries[] = array($langs->trans("Other"), round($rest));
|
||||
}
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||
@ -200,8 +220,7 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
|
||||
$dolgraph->draw('idgraphcateg');
|
||||
print $dolgraph->show();
|
||||
} else {
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
|
||||
@ -234,24 +253,30 @@ $sql .= ", s.logo";
|
||||
$sql .= ", s.entity";
|
||||
$sql .= ", s.canvas, s.tms as date_modification, s.status as status";
|
||||
$sql .= " FROM ".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 s.entity IN ('.getEntity('societe').')';
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
if ($socid) $sql .= " AND s.rowid = ".$socid;
|
||||
if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur != 1 OR s.client != 0)";
|
||||
if (!$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
if ($socid) {
|
||||
$sql .= " AND s.rowid = ".$socid;
|
||||
}
|
||||
if (!$user->rights->fournisseur->lire) {
|
||||
$sql .= " AND (s.fournisseur != 1 OR s.client != 0)";
|
||||
}
|
||||
$sql .= $db->order("s.tms", "DESC");
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
//print $sql;
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
if ($num > 0) {
|
||||
$transRecordedType = $langs->trans("LastModifiedThirdParties", $max);
|
||||
|
||||
print "\n<!-- last thirdparties modified -->\n";
|
||||
@ -263,8 +288,7 @@ if ($result)
|
||||
print '<th class="right"><a href="'.DOL_URL_ROOT.'/societe/list.php?sortfield=s.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$thirdparty_static->id = $objp->rowid;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -35,11 +35,15 @@ $langs->load("companies");
|
||||
|
||||
// Security check
|
||||
$id = GETPOST('id') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
|
||||
if ($user->socid) $id = $user->socid;
|
||||
if ($user->socid) {
|
||||
$id = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'societe', $id, '&societe');
|
||||
|
||||
$object = new Societe($db);
|
||||
if ($id > 0) $object->fetch($id);
|
||||
if ($id > 0) {
|
||||
$object->fetch($id);
|
||||
}
|
||||
|
||||
$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php
|
||||
|
||||
@ -61,16 +65,19 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include,
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans("ThirdParty").' - '.$langs->trans("Notes");
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Notes");
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
|
||||
$title = $object->name.' - '.$langs->trans("Notes");
|
||||
}
|
||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if ($object->id > 0)
|
||||
{
|
||||
if ($object->id > 0) {
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
if (!empty($conf->notification->enabled)) $langs->load("mails");
|
||||
* Affichage onglets
|
||||
*/
|
||||
if (!empty($conf->notification->enabled)) {
|
||||
$langs->load("mails");
|
||||
}
|
||||
|
||||
$head = societe_prepare_head($object);
|
||||
|
||||
@ -89,32 +96,31 @@ if ($object->id > 0)
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
||||
{
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
|
||||
print '<tr><td class="'.$cssclass.'">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
||||
}
|
||||
|
||||
if ($object->client) {
|
||||
print '<tr><td class="'.$cssclass.'">';
|
||||
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
|
||||
$tmpcheck = $object->check_codeclient();
|
||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
if ($object->client) {
|
||||
print '<tr><td class="'.$cssclass.'">';
|
||||
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
|
||||
$tmpcheck = $object->check_codeclient();
|
||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ($object->fournisseur) {
|
||||
print '<tr><td class="'.$cssclass.'">';
|
||||
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
|
||||
$tmpcheck = $object->check_codefournisseur();
|
||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
if ($object->fournisseur) {
|
||||
print '<tr><td class="'.$cssclass.'">';
|
||||
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
|
||||
$tmpcheck = $object->check_codefournisseur();
|
||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
@ -39,16 +39,24 @@ $actionid = GETPOST('actionid');
|
||||
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'societe', '', '');
|
||||
|
||||
$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 (!$sortorder) $sortorder = "DESC";
|
||||
if (!$sortfield) $sortfield = "n.daten";
|
||||
if (empty($page) || $page == -1) { $page = 0; }
|
||||
if (!$sortorder) {
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "n.daten";
|
||||
}
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
@ -68,39 +76,34 @@ $hookmanager->initHooks(array('thirdpartynotification', 'globalcard'));
|
||||
|
||||
$parameters = array('id'=>$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');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
$error = 0;
|
||||
|
||||
// Add a notification
|
||||
if ($action == 'add')
|
||||
{
|
||||
if (empty($contactid))
|
||||
{
|
||||
if ($action == 'add') {
|
||||
if (empty($contactid)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Contact")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if ($actionid <= 0)
|
||||
{
|
||||
if ($actionid <= 0) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
|
||||
$sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$contactid." AND fk_action=".$actionid;
|
||||
if ($db->query($sql))
|
||||
{
|
||||
if ($db->query($sql)) {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)";
|
||||
$sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")";
|
||||
|
||||
if (!$db->query($sql))
|
||||
{
|
||||
if (!$db->query($sql)) {
|
||||
$error++;
|
||||
dol_print_error($db);
|
||||
}
|
||||
@ -108,8 +111,7 @@ if (empty($reshook))
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
@ -118,8 +120,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Remove a notification
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST('actid', 'int');
|
||||
$db->query($sql);
|
||||
}
|
||||
@ -137,14 +138,15 @@ $object = new Societe($db);
|
||||
$result = $object->fetch($socid);
|
||||
|
||||
$title = $langs->trans("ThirdParty").' - '.$langs->trans("Notification");
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Notification");
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
|
||||
$title = $object->name.' - '.$langs->trans("Notification");
|
||||
}
|
||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$langs->load("other");
|
||||
|
||||
$head = societe_prepare_head($object);
|
||||
@ -161,44 +163,43 @@ if ($result > 0)
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
// Prefix
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
||||
{
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
|
||||
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
||||
}
|
||||
|
||||
if ($object->client) {
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
|
||||
$tmpcheck = $object->check_codeclient();
|
||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
if ($object->client) {
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
|
||||
$tmpcheck = $object->check_codeclient();
|
||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
|
||||
$tmpcheck = $object->check_codefournisseur();
|
||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
|
||||
$tmpcheck = $object->check_codefournisseur();
|
||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
/*print '<tr><td class="titlefield">'.$langs->trans("NbOfActiveNotifications").'</td>'; // Notification for this thirdparty
|
||||
print '<td colspan="3">';
|
||||
$nbofrecipientemails=0;
|
||||
$notify=new Notify($db);
|
||||
$tmparray = $notify->getNotificationsArray('', $object->id, null, 0, array('thirdparty'));
|
||||
foreach($tmparray as $tmpkey => $tmpval)
|
||||
{
|
||||
if (! empty($tmpkey)) $nbofrecipientemails++;
|
||||
}
|
||||
print $nbofrecipientemails;
|
||||
print '</td></tr>';*/
|
||||
print '<td colspan="3">';
|
||||
$nbofrecipientemails=0;
|
||||
$notify=new Notify($db);
|
||||
$tmparray = $notify->getNotificationsArray('', $object->id, null, 0, array('thirdparty'));
|
||||
foreach($tmparray as $tmpkey => $tmpval)
|
||||
{
|
||||
if (! empty($tmpkey)) $nbofrecipientemails++;
|
||||
}
|
||||
print $nbofrecipientemails;
|
||||
print '</td></tr>';*/
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -232,8 +233,7 @@ if ($result > 0)
|
||||
$sql .= " AND c.fk_soc = ".$object->id;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
@ -261,17 +261,15 @@ if ($result > 0)
|
||||
|
||||
// Line to add a new subscription
|
||||
$listofemails = $object->thirdparty_and_contact_email_array();
|
||||
if (count($listofemails) > 0)
|
||||
{
|
||||
if (count($listofemails) > 0) {
|
||||
$actions = array();
|
||||
|
||||
// Load array of available notifications
|
||||
$notificationtrigger = new InterfaceNotification($db);
|
||||
$listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents();
|
||||
|
||||
foreach ($listofmanagedeventfornotification as $managedeventfornotification)
|
||||
{
|
||||
$label = ($langs->trans("Notify_".$managedeventfornotification['code']) != "Notify_".$managedeventfornotification['code'] ? $langs->trans("Notify_".$managedeventfornotification['code']) : $managedeventfornotification['label']);
|
||||
foreach ($listofmanagedeventfornotification as $managedeventfornotification) {
|
||||
$label = ($langs->trans("Notify_".$managedeventfornotification['code']) != "Notify_".$managedeventfornotification['code'] ? $langs->trans("Notify_".$managedeventfornotification['code']) : $managedeventfornotification['label']);
|
||||
$actions[$managedeventfornotification['rowid']] = $label;
|
||||
}
|
||||
print '<tr class="oddeven nohover">';
|
||||
@ -294,14 +292,12 @@ if ($result > 0)
|
||||
}
|
||||
|
||||
|
||||
if ($num)
|
||||
{
|
||||
if ($num) {
|
||||
$i = 0;
|
||||
|
||||
$contactstatic = new Contact($db);
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$contactstatic->id = $obj->contact_id;
|
||||
@ -310,10 +306,8 @@ if ($result > 0)
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$contactstatic->getNomUrl(1);
|
||||
if ($obj->type == 'email')
|
||||
{
|
||||
if (isValidEmail($obj->email))
|
||||
{
|
||||
if ($obj->type == 'email') {
|
||||
if (isValidEmail($obj->email)) {
|
||||
print ' <'.$obj->email.'>';
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
@ -326,8 +320,12 @@ if ($result > 0)
|
||||
print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label;
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($obj->type == 'email') print $langs->trans("Email");
|
||||
if ($obj->type == 'sms') print $langs->trans("SMS");
|
||||
if ($obj->type == 'email') {
|
||||
print $langs->trans("Email");
|
||||
}
|
||||
if ($obj->type == 'sms') {
|
||||
print $langs->trans("SMS");
|
||||
}
|
||||
print '</td>';
|
||||
print '<td class="right"><a href="card.php?socid='.$socid.'&action=delete&token='.newToken().'&actid='.$obj->rowid.'">'.img_delete().'</a></td>';
|
||||
print '</tr>';
|
||||
@ -338,9 +336,9 @@ if ($result > 0)
|
||||
|
||||
// List of notifications enabled for fixed email
|
||||
/*
|
||||
foreach($conf->global as $key => $val)
|
||||
{
|
||||
if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue;
|
||||
foreach($conf->global as $key => $val)
|
||||
{
|
||||
if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue;
|
||||
print '<tr class="oddeven"><td>';
|
||||
$listtmp=explode(',',$val);
|
||||
$first=1;
|
||||
@ -349,7 +347,7 @@ if ($result > 0)
|
||||
if (! $first) print ', ';
|
||||
$first=0;
|
||||
$valemail=trim($valemail);
|
||||
//print $keyemail.' - '.$valemail.' - '.$reg[1].'<br>';
|
||||
//print $keyemail.' - '.$valemail.' - '.$reg[1].'<br>';
|
||||
if (isValidEmail($valemail, 1))
|
||||
{
|
||||
if ($valemail == '__SUPERVISOREMAIL__') print $valemail;
|
||||
@ -377,14 +375,14 @@ if ($result > 0)
|
||||
print '</td>';
|
||||
print '<td class="right">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</td>';
|
||||
print '</tr>';
|
||||
}*/
|
||||
}*/
|
||||
|
||||
/*if ($user->admin)
|
||||
{
|
||||
{
|
||||
print '<tr class="oddeven"><td colspan="4">';
|
||||
print '+ <a href="'.DOL_URL_ROOT.'/admin/notification.php">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</a>';
|
||||
print '</td></tr>';
|
||||
}*/
|
||||
}*/
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
@ -406,12 +404,10 @@ if ($result > 0)
|
||||
|
||||
// Count total nb of records
|
||||
$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);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
@ -420,19 +416,24 @@ if ($result > 0)
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$param = '&socid='.$object->id;
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.$contextpage;
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.$limit;
|
||||
}
|
||||
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
|
||||
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="sortfield" value="'.$sortfield.'">';
|
||||
@ -454,19 +455,16 @@ if ($result > 0)
|
||||
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
print '</tr>';
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
if ($num > 0) {
|
||||
$i = 0;
|
||||
|
||||
$contactstatic = new Contact($db);
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
if ($obj->id > 0)
|
||||
{
|
||||
if ($obj->id > 0) {
|
||||
$contactstatic->id = $obj->id;
|
||||
$contactstatic->lastname = $obj->lastname;
|
||||
$contactstatic->firstname = $obj->firstname;
|
||||
@ -481,18 +479,22 @@ if ($result > 0)
|
||||
print $label;
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($obj->type == 'email') print $langs->trans("Email");
|
||||
if ($obj->type == 'sms') print $langs->trans("Sms");
|
||||
if ($obj->type == 'email') {
|
||||
print $langs->trans("Email");
|
||||
}
|
||||
if ($obj->type == 'sms') {
|
||||
print $langs->trans("Sms");
|
||||
}
|
||||
print '</td>';
|
||||
// TODO Add link to object here for other types
|
||||
/*print '<td>';
|
||||
if ($obj->object_type == 'order')
|
||||
{
|
||||
if ($obj->object_type == 'order')
|
||||
{
|
||||
$orderstatic->id=$obj->object_id;
|
||||
$orderstatic->ref=...
|
||||
print $orderstatic->getNomUrl(1);
|
||||
}
|
||||
print '</td>';*/
|
||||
}
|
||||
print '</td>';*/
|
||||
// print
|
||||
print'<td class="right">'.dol_print_date($db->jdate($obj->daten), 'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
@ -507,7 +509,9 @@ if ($result > 0)
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
} else dol_print_error('', 'RecordNotFound');
|
||||
} else {
|
||||
dol_print_error('', 'RecordNotFound');
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -49,8 +49,9 @@ $search_price_ttc = GETPOST('search_price_ttc');
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
|
||||
if ($user->socid)
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'societe', $socid, '&societe');
|
||||
|
||||
$object = new Societe($db);
|
||||
@ -67,12 +68,12 @@ $error = 0;
|
||||
|
||||
$parameters = array('id'=>$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');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
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 (empty($reshook)) {
|
||||
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_prod = $search_label = $search_price = $search_price_ttc = '';
|
||||
}
|
||||
|
||||
@ -102,8 +103,7 @@ if (empty($reshook))
|
||||
$npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
|
||||
$localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0';
|
||||
// If value contains the unique code of vat line (new recommended method), we use it to find npr and local taxes
|
||||
if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg))
|
||||
{
|
||||
if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) {
|
||||
// We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price.
|
||||
$vatratecode = $reg[1];
|
||||
// Get record from code
|
||||
@ -113,8 +113,7 @@ if (empty($reshook))
|
||||
$sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1";
|
||||
$sql .= " AND t.code ='".$db->escape($vatratecode)."'";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$npr = $obj->recuperableonly;
|
||||
$localtax1 = $obj->localtax1;
|
||||
@ -193,8 +192,9 @@ $object = new Societe($db);
|
||||
$result = $object->fetch($socid);
|
||||
llxHeader("", $langs->trans("ThirdParty").'-'.$langs->trans('PriceByCustomer'));
|
||||
|
||||
if (!empty($conf->notification->enabled))
|
||||
if (!empty($conf->notification->enabled)) {
|
||||
$langs->load("mails");
|
||||
}
|
||||
$head = societe_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company');
|
||||
@ -208,8 +208,7 @@ print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
||||
{
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
|
||||
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
||||
}
|
||||
|
||||
@ -250,14 +249,18 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$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;
|
||||
if (!$sortorder)
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
if (!$sortfield)
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "soc.nom";
|
||||
}
|
||||
|
||||
// Build filter to display only concerned lines
|
||||
$filter = array(
|
||||
@ -365,8 +368,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
||||
print load_fiche_titre($langs->trans('PriceByCustomer'));
|
||||
|
||||
$result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
|
||||
}
|
||||
|
||||
@ -457,8 +459,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
||||
}
|
||||
|
||||
$result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
|
||||
}
|
||||
|
||||
@ -537,14 +538,12 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
|
||||
}
|
||||
|
||||
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
|
||||
}
|
||||
|
||||
@ -575,8 +574,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
if (count($prodcustprice->lines) > 0 || $search_prod)
|
||||
{
|
||||
if (count($prodcustprice->lines) > 0 || $search_prod) {
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="'.$search_prod.'" size="20"></td>';
|
||||
print '<td class="liste_titre" ><input type="text" class="flat" name="search_label" value="'.$search_label.'" size="20"></td>';
|
||||
@ -592,10 +590,8 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (count($prodcustprice->lines) > 0)
|
||||
{
|
||||
foreach ($prodcustprice->lines as $line)
|
||||
{
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
foreach ($prodcustprice->lines as $line) {
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
$staticprod = new Product($db);
|
||||
@ -621,8 +617,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
||||
print '</td>';
|
||||
|
||||
// Action
|
||||
if ($user->rights->produit->creer || $user->rights->service->creer)
|
||||
{
|
||||
if ($user->rights->produit->creer || $user->rights->service->creer) {
|
||||
print '<td class="right nowraponall">';
|
||||
print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&socid='.$object->id.'&prodid='.$line->fk_product.'">';
|
||||
print img_info();
|
||||
@ -642,7 +637,9 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
||||
}
|
||||
} else {
|
||||
$colspan = 10;
|
||||
if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan += 1;
|
||||
if ($user->rights->produit->supprimer || $user->rights->service->supprimer) {
|
||||
$colspan += 1;
|
||||
}
|
||||
print '<tr class="oddeven"><td colspan="'.$colspan.'">'.$langs->trans('None').'</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,9 @@ $langs->loadLangs(array("companies", "projects"));
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST('socid', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'societe', $socid, '&societe');
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
@ -48,7 +50,9 @@ $hookmanager->initHooks(array('projectthirdparty'));
|
||||
|
||||
$parameters = array('id'=>$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');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -60,8 +64,7 @@ $contactstatic = new Contact($db);
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
if ($socid)
|
||||
{
|
||||
if ($socid) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
|
||||
@ -72,10 +75,14 @@ if ($socid)
|
||||
$result = $object->fetch($socid);
|
||||
|
||||
$title = $langs->trans("Projects");
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title;
|
||||
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
|
||||
$title = $object->name." - ".$title;
|
||||
}
|
||||
llxHeader('', $title);
|
||||
|
||||
if (!empty($conf->notification->enabled)) $langs->load("mails");
|
||||
if (!empty($conf->notification->enabled)) {
|
||||
$langs->load("mails");
|
||||
}
|
||||
$head = societe_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company');
|
||||
@ -89,13 +96,11 @@ if ($socid)
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
||||
{
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
|
||||
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
||||
}
|
||||
|
||||
if ($object->client)
|
||||
{
|
||||
if ($object->client) {
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
|
||||
@ -106,8 +111,7 @@ if ($socid)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ($object->fournisseur)
|
||||
{
|
||||
if ($object->fournisseur) {
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
||||
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
|
||||
|
||||
@ -43,15 +43,23 @@ $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 (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) $sortfield = "s.nom";
|
||||
if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; }
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "s.nom";
|
||||
}
|
||||
if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'societe', $id, '');
|
||||
|
||||
$object = new Societe($db);
|
||||
@ -64,51 +72,39 @@ $hookmanager->initHooks(array('contactthirdparty', 'globalcard'));
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'addcontact' && $user->rights->societe->creer)
|
||||
{
|
||||
if ($action == 'addcontact' && $user->rights->societe->creer) {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
if ($result > 0 && $id > 0)
|
||||
{
|
||||
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 {
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
|
||||
} else {
|
||||
$mesg = '<div class="error">'.$object->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bascule du statut d'un contact
|
||||
elseif ($action == 'swapstatut' && $user->rights->societe->creer)
|
||||
{
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
} elseif ($action == 'swapstatut' && $user->rights->societe->creer) {
|
||||
// bascule du statut d'un contact
|
||||
if ($object->fetch($id)) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne'));
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// Efface un contact
|
||||
elseif ($action == 'deletecontact' && $user->rights->societe->creer)
|
||||
{
|
||||
} elseif ($action == 'deletecontact' && $user->rights->societe->creer) {
|
||||
// Efface un contact
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact($_GET["lineid"]);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
@ -145,10 +141,8 @@ $userstatic = new User($db);
|
||||
/* */
|
||||
/* *************************************************************************** */
|
||||
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
if ($object->fetch($id, $ref) > 0)
|
||||
{
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
if ($object->fetch($id, $ref) > 0) {
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($object->socid);
|
||||
|
||||
@ -169,41 +163,38 @@ if ($id > 0 || !empty($ref))
|
||||
|
||||
// Prospect/Customer
|
||||
/*print '<tr><td class="titlefield">'.$langs->trans('ProspectCustomer').'</td><td>';
|
||||
print $object->getLibCustProspStatut();
|
||||
print '</td></tr>';
|
||||
print $object->getLibCustProspStatut();
|
||||
print '</td></tr>';
|
||||
|
||||
// Supplier
|
||||
print '<tr><td>'.$langs->trans('Supplier').'</td><td>';
|
||||
print yn($object->fournisseur);
|
||||
print '</td></tr>';*/
|
||||
// Supplier
|
||||
print '<tr><td>'.$langs->trans('Supplier').'</td><td>';
|
||||
print yn($object->fournisseur);
|
||||
print '</td></tr>';*/
|
||||
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
||||
{
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
|
||||
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
||||
}
|
||||
|
||||
if ($object->client)
|
||||
{
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
||||
print $object->code_client;
|
||||
$tmpcheck = $object->check_codeclient();
|
||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
if ($object->client) {
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
||||
print $object->code_client;
|
||||
$tmpcheck = $object->check_codeclient();
|
||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ($object->fournisseur)
|
||||
{
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
||||
print $object->code_fournisseur;
|
||||
$tmpcheck = $object->check_codefournisseur();
|
||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
if ($object->fournisseur) {
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
||||
print $object->code_fournisseur;
|
||||
$tmpcheck = $object->check_codefournisseur();
|
||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
@ -214,15 +205,15 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
// additionnal list with adherents of company
|
||||
if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire)
|
||||
{
|
||||
if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
|
||||
|
||||
@ -241,12 +232,10 @@ if ($id > 0 || !empty($ref))
|
||||
|
||||
dol_syslog("get list sql=".$sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
if ($num > 0) {
|
||||
$param = '';
|
||||
|
||||
$titre = $langs->trans("MembersListOfTiers");
|
||||
@ -267,8 +256,7 @@ if ($id > 0 || !empty($ref))
|
||||
print "</tr>\n";
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num && $i < $conf->liste_limit)
|
||||
{
|
||||
while ($i < $num && $i < $conf->liste_limit) {
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
$datefin = $db->jdate($objp->datefin);
|
||||
@ -319,8 +307,7 @@ if ($id > 0 || !empty($ref))
|
||||
print "</td>";
|
||||
|
||||
// End of subscription date
|
||||
if ($datefin)
|
||||
{
|
||||
if ($datefin) {
|
||||
print '<td class="center nowrap">';
|
||||
print dol_print_date($datefin, 'day');
|
||||
if ($memberstatic->hasDelay()) {
|
||||
@ -329,10 +316,11 @@ if ($id > 0 || !empty($ref))
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td class="left nowrap">';
|
||||
if ($objp->subscription == 'yes')
|
||||
{
|
||||
if ($objp->subscription == 'yes') {
|
||||
print $langs->trans("SubscriptionNotReceived");
|
||||
if ($objp->statut > 0) print " ".img_warning();
|
||||
if ($objp->statut > 0) {
|
||||
print " ".img_warning();
|
||||
}
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
|
||||
@ -67,6 +67,8 @@ if ($action == 'editsalesrepresentatives') {
|
||||
print $userstatic->getNomUrl(-1);
|
||||
print ' ';
|
||||
}
|
||||
} else print '<span class="opacitymedium">'.$langs->trans("NoSalesRepresentativeAffected").'</span>';
|
||||
} else {
|
||||
print '<span class="opacitymedium">'.$langs->trans("NoSalesRepresentativeAffected").'</span>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -47,19 +47,27 @@ $search_status = GETPOST('search_status');
|
||||
|
||||
// Security check
|
||||
$id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'societe', $socid, '&societe');
|
||||
|
||||
$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 = 't.login';
|
||||
if (!$sortorder) $sortorder = 'ASC';
|
||||
if (!$sortfield) {
|
||||
$sortfield = 't.login';
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = 'ASC';
|
||||
}
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Societe($db);
|
||||
@ -78,24 +86,27 @@ unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are alr
|
||||
// Initialize array of search criterias
|
||||
$search_all = GETPOST("search_all", 'alpha');
|
||||
$search = array();
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val)
|
||||
{
|
||||
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
|
||||
foreach ($objectwebsiteaccount->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 ($objectwebsiteaccount->fields as $key => $val)
|
||||
{
|
||||
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val) {
|
||||
if ($val['searchall']) {
|
||||
$fieldstosearchall['t.'.$key] = $val['label'];
|
||||
}
|
||||
}
|
||||
|
||||
// Definition of fields for list
|
||||
$arrayfields = array();
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val)
|
||||
{
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val) {
|
||||
// If $val['visible']==0, then we never show the field
|
||||
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled']);
|
||||
if (!empty($val['visible'])) {
|
||||
$arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled']);
|
||||
}
|
||||
}
|
||||
|
||||
// Extra fields
|
||||
@ -105,8 +116,7 @@ $object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
$result = $object->fetch($id);
|
||||
}
|
||||
|
||||
@ -117,13 +127,13 @@ if ($id > 0)
|
||||
|
||||
$parameters = array('id'=>$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');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Cancel
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
|
||||
{
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
@ -132,18 +142,15 @@ if (empty($reshook))
|
||||
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 ($objectwebsiteaccount->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 ($objectwebsiteaccount->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
|
||||
}
|
||||
|
||||
@ -172,14 +179,21 @@ $title = $langs->trans("WebsiteAccounts");
|
||||
llxHeader('', $title);
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($id > 0) $param .= '&id='.urlencode($id);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
foreach ($search as $key => $val)
|
||||
{
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($id > 0) {
|
||||
$param .= '&id='.urlencode($id);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
foreach ($search as $key => $val) {
|
||||
$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';
|
||||
|
||||
@ -198,8 +212,7 @@ print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
// Prefix
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
||||
{
|
||||
if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
|
||||
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
||||
}
|
||||
|
||||
@ -247,29 +260,39 @@ print '<br>';
|
||||
// Build and execute select
|
||||
// --------------------------------------------------------------------
|
||||
$sql = 'SELECT ';
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val)
|
||||
{
|
||||
foreach ($objectwebsiteaccount->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.', ' : '');
|
||||
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.', ' : '');
|
||||
}
|
||||
}
|
||||
// Add fields from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
$sql = preg_replace('/, $/', '', $sql);
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_account 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 ($objectwebsiteaccount->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity('societeaccount').")";
|
||||
else $sql .= " WHERE 1 = 1";
|
||||
$sql .= " AND fk_soc = ".$object->id;
|
||||
foreach ($search as $key => $val)
|
||||
{
|
||||
$mode_search = (($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key])) ? 1 : 0);
|
||||
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
|
||||
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 ($objectwebsiteaccount->ismultientitymanaged == 1) {
|
||||
$sql .= " WHERE t.entity IN (".getEntity('societeaccount').")";
|
||||
} else {
|
||||
$sql .= " WHERE 1 = 1";
|
||||
}
|
||||
$sql .= " AND fk_soc = ".$object->id;
|
||||
foreach ($search as $key => $val) {
|
||||
$mode_search = (($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key])) ? 1 : 0);
|
||||
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);
|
||||
// Add where from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||
// Add where from hooks
|
||||
@ -296,12 +319,10 @@ $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)) {
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
@ -310,8 +331,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
@ -325,12 +345,18 @@ $arrayofmassactions = array(
|
||||
//'presend'=>$langs->trans("SendByMail"),
|
||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
|
||||
if ($user->rights->mymodule->delete) {
|
||||
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||
}
|
||||
if (in_array($massaction, array('presend', 'predelete'))) {
|
||||
$arrayofmassactions = array();
|
||||
}
|
||||
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
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">';
|
||||
@ -361,11 +387,13 @@ $moreforfilter.= '</div>';*/
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount 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>';
|
||||
@ -382,13 +410,20 @@ print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" :
|
||||
// Fields title search
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val)
|
||||
{
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val) {
|
||||
$align = '';
|
||||
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align .= ' nowrap';
|
||||
if ($key == 'status') $align .= ($align ? ' ' : '').'center';
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
|
||||
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$align = 'center';
|
||||
}
|
||||
if (in_array($val['type'], array('timestamp'))) {
|
||||
$align .= ' nowrap';
|
||||
}
|
||||
if ($key == 'status') {
|
||||
$align .= ($align ? ' ' : '').'center';
|
||||
}
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
|
||||
}
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||
@ -407,13 +442,20 @@ print '</tr>'."\n";
|
||||
// Fields title label
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val)
|
||||
{
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val) {
|
||||
$align = '';
|
||||
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align .= 'nowrap';
|
||||
if ($key == 'status') $align .= ($align ? ' ' : '').'center';
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n";
|
||||
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$align = 'center';
|
||||
}
|
||||
if (in_array($val['type'], array('timestamp'))) {
|
||||
$align .= 'nowrap';
|
||||
}
|
||||
if ($key == 'status') {
|
||||
$align .= ($align ? ' ' : '').'center';
|
||||
}
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n";
|
||||
}
|
||||
}
|
||||
// Extra fields
|
||||
// Extra fields
|
||||
@ -428,11 +470,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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -440,40 +482,54 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
|
||||
// --------------------------------------------------------------------
|
||||
$i = 0;
|
||||
$totalarray = array();
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
while ($i < min($num, $limit)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if (empty($obj)) break; // Should not happen
|
||||
if (empty($obj)) {
|
||||
break; // Should not happen
|
||||
}
|
||||
|
||||
// Store properties in $object
|
||||
$objectwebsiteaccount->id = $obj->rowid;
|
||||
$objectwebsiteaccount->login = $obj->login;
|
||||
$objectwebsiteaccount->ref = $obj->login;
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val)
|
||||
{
|
||||
if (property_exists($obj, $key)) $object->$key = $obj->$key;
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val) {
|
||||
if (property_exists($obj, $key)) {
|
||||
$object->$key = $obj->$key;
|
||||
}
|
||||
}
|
||||
|
||||
// Show here line of result
|
||||
print '<tr class="oddeven">';
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val)
|
||||
{
|
||||
foreach ($objectwebsiteaccount->fields as $key => $val) {
|
||||
$align = '';
|
||||
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align .= 'nowrap';
|
||||
if ($key == 'status') $align .= ($align ? ' ' : '').'center';
|
||||
if (!empty($arrayfields['t.'.$key]['checked']))
|
||||
{
|
||||
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$align = 'center';
|
||||
}
|
||||
if (in_array($val['type'], array('timestamp'))) {
|
||||
$align .= 'nowrap';
|
||||
}
|
||||
if ($key == 'status') {
|
||||
$align .= ($align ? ' ' : '').'center';
|
||||
}
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
print '<td';
|
||||
if ($align) print ' class="'.$align.'"';
|
||||
if ($align) {
|
||||
print ' class="'.$align.'"';
|
||||
}
|
||||
print '>';
|
||||
if ($key == 'login') print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1);
|
||||
else print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, '');
|
||||
if ($key == 'login') {
|
||||
print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1);
|
||||
} else {
|
||||
print $objectwebsiteaccount->showOutputField($val, $key, $obj->$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] += $obj->$key;
|
||||
}
|
||||
}
|
||||
@ -486,14 +542,17 @@ while ($i < min($num, $limit))
|
||||
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($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>';
|
||||
|
||||
@ -505,10 +564,13 @@ 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>';
|
||||
}
|
||||
|
||||
@ -524,10 +586,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);
|
||||
|
||||
@ -37,7 +37,9 @@ $servicename = 'Stripe';
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'other', 'paypal', 'paybox', 'stripe'));
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
@ -46,64 +48,79 @@ $action = GETPOST('action', 'aZ09');
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'setvalue' && $user->admin)
|
||||
{
|
||||
if ($action == 'setvalue' && $user->admin) {
|
||||
$db->begin();
|
||||
|
||||
if (empty($conf->stripeconnect->enabled)) {
|
||||
$result = dolibarr_set_const($db, "STRIPE_TEST_PUBLISHABLE_KEY", GETPOST('STRIPE_TEST_PUBLISHABLE_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY", GETPOST('STRIPE_TEST_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_ID", GETPOST('STRIPE_TEST_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_KEY", GETPOST('STRIPE_TEST_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "STRIPE_LIVE_PUBLISHABLE_KEY", GETPOST('STRIPE_LIVE_PUBLISHABLE_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY", GETPOST('STRIPE_LIVE_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_ID", GETPOST('STRIPE_LIVE_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_KEY", GETPOST('STRIPE_LIVE_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR", GETPOST('ONLINE_PAYMENT_CREDITOR', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_PAYMENTS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 'int'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "STRIPE_USER_ACCOUNT_FOR_ACTIONS", GETPOST('STRIPE_USER_ACCOUNT_FOR_ACTIONS', 'int'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 'int'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM", GETPOST('ONLINE_PAYMENT_MESSAGE_FORM', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK", GETPOST('ONLINE_PAYMENT_MESSAGE_OK', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_KO", GETPOST('ONLINE_PAYMENT_MESSAGE_KO', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL", GETPOST('ONLINE_PAYMENT_SENDEMAIL'), 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0)
|
||||
if (!$result > 0) {
|
||||
$error++;
|
||||
}
|
||||
// Stock decrement
|
||||
//$result = dolibarr_set_const($db, "ONLINE_PAYMENT_WAREHOUSE", (GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') > 0 ? GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
|
||||
//if (! $result > 0)
|
||||
@ -130,8 +147,7 @@ if ($action == 'setvalue' && $user->admin)
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == "setlive")
|
||||
{
|
||||
if ($action == "setlive") {
|
||||
$liveenable = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "STRIPE_LIVE", $liveenable, 'yesno', 0, '', $conf->entity);
|
||||
if ($res > 0) {
|
||||
@ -188,8 +204,7 @@ if ($conf->use_javascript_ajax) {
|
||||
}
|
||||
print '</td><td></td></tr>';
|
||||
|
||||
if (empty($conf->stripeconnect->enabled))
|
||||
{
|
||||
if (empty($conf->stripeconnect->enabled)) {
|
||||
print '<tr class="oddeven"><td>';
|
||||
print '<span class="fieldrequired">'.$langs->trans("STRIPE_TEST_PUBLISHABLE_KEY").'</span></td><td>';
|
||||
print '<input class="minwidth300" type="text" name="STRIPE_TEST_PUBLISHABLE_KEY" value="'.$conf->global->STRIPE_TEST_PUBLISHABLE_KEY.'">';
|
||||
@ -216,10 +231,8 @@ if (empty($conf->stripeconnect->enabled))
|
||||
$out .= ajax_autoselect("onlinetestwebhookurl", 0);
|
||||
print '<br>'.$out;
|
||||
print '</td><td>';
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
{
|
||||
if (!empty($conf->global->STRIPE_TEST_WEBHOOK_KEY) && !empty($conf->global->STRIPE_TEST_SECRET_KEY) && !empty($conf->global->STRIPE_TEST_WEBHOOK_ID))
|
||||
{
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
|
||||
if (!empty($conf->global->STRIPE_TEST_WEBHOOK_KEY) && !empty($conf->global->STRIPE_TEST_SECRET_KEY) && !empty($conf->global->STRIPE_TEST_WEBHOOK_ID)) {
|
||||
\Stripe\Stripe::setApiKey($conf->global->STRIPE_TEST_SECRET_KEY);
|
||||
$endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID);
|
||||
$endpoint->enabled_events = $stripearrayofwebhookevents;
|
||||
@ -232,8 +245,7 @@ if (empty($conf->stripeconnect->enabled))
|
||||
}
|
||||
$endpoint->url = dol_buildpath('/public/stripe/ipn.php?test', 3);
|
||||
$endpoint->save();
|
||||
if ($endpoint->status == 'enabled')
|
||||
{
|
||||
if ($endpoint->status == 'enabled') {
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
} else {
|
||||
@ -257,8 +269,7 @@ if (empty($conf->stripeconnect->enabled))
|
||||
print '</td><td></td></tr>';
|
||||
}
|
||||
|
||||
if (empty($conf->stripeconnect->enabled))
|
||||
{
|
||||
if (empty($conf->stripeconnect->enabled)) {
|
||||
print '<tr class="oddeven"><td>';
|
||||
print '<span class="fieldrequired">'.$langs->trans("STRIPE_LIVE_PUBLISHABLE_KEY").'</span></td><td>';
|
||||
print '<input class="minwidth300" type="text" name="STRIPE_LIVE_PUBLISHABLE_KEY" value="'.$conf->global->STRIPE_LIVE_PUBLISHABLE_KEY.'">';
|
||||
@ -285,10 +296,8 @@ if (empty($conf->stripeconnect->enabled))
|
||||
$out .= ajax_autoselect("onlinelivewebhookurl", 0);
|
||||
print '<br>'.$out;
|
||||
print '</td><td>';
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
{
|
||||
if (!empty($conf->global->STRIPE_LIVE_WEBHOOK_KEY) && !empty($conf->global->STRIPE_LIVE_SECRET_KEY) && !empty($conf->global->STRIPE_LIVE_WEBHOOK_ID))
|
||||
{
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
|
||||
if (!empty($conf->global->STRIPE_LIVE_WEBHOOK_KEY) && !empty($conf->global->STRIPE_LIVE_SECRET_KEY) && !empty($conf->global->STRIPE_LIVE_WEBHOOK_ID)) {
|
||||
\Stripe\Stripe::setApiKey($conf->global->STRIPE_LIVE_SECRET_KEY);
|
||||
$endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_LIVE_WEBHOOK_ID);
|
||||
$endpoint->enabled_events = $stripearrayofwebhookevents;
|
||||
@ -301,8 +310,7 @@ if (empty($conf->stripeconnect->enabled))
|
||||
}
|
||||
$endpoint->url = dol_buildpath('/public/stripe/ipn.php', 3);
|
||||
$endpoint->save();
|
||||
if ($endpoint->status == 'enabled')
|
||||
{
|
||||
if ($endpoint->status == 'enabled') {
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
} else {
|
||||
@ -351,8 +359,7 @@ print img_picto('', 'bank_account').' ';
|
||||
$form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS, 'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is this for ?
|
||||
{
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // What is this for ?
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("BankAccountForBankTransfer").'</td><td>';
|
||||
$form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS, 'STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 0, '', 1);
|
||||
@ -360,8 +367,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is this for ?
|
||||
}
|
||||
|
||||
// Activate Payment Request API
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
|
||||
{
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("STRIPE_PAYMENT_REQUEST_API").'</td><td>';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
@ -374,8 +380,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
|
||||
}
|
||||
|
||||
// Activate SEPA DIRECT_DEBIT
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
|
||||
{
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").'</td><td>';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
@ -388,8 +393,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
|
||||
}
|
||||
|
||||
// Activate Bancontact
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
|
||||
{
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("STRIPE_BANCONTACT").'</td><td>';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
@ -403,8 +407,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
|
||||
}
|
||||
|
||||
// Activate iDEAL
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
|
||||
{
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("STRIPE_IDEAL").'</td><td>';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
@ -418,8 +421,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
|
||||
}
|
||||
|
||||
// Activate Giropay
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
|
||||
{
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("STRIPE_GIROPAY").'</td><td>';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
@ -433,8 +435,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
|
||||
}
|
||||
|
||||
// Activate Sofort
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
|
||||
{
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("STRIPE_SOFORT").'</td><td>';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
@ -540,8 +541,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php';
|
||||
|
||||
print info_admin($langs->trans("ExampleOfTestCreditCard", '4242424242424242 (no 3DSecure) or 4000000000003063 (3DSecure required) or 4000002760003184 (3DSecure2 required on all transaction) or 4000003800000446 (3DSecure2 required, the off-session allowed)', '4000000000000101', '4000000000000069', '4000000000000341'));
|
||||
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print "\n".'<script type="text/javascript">';
|
||||
print '$(document).ready(function () {
|
||||
$("#apidoc").hide();
|
||||
|
||||
@ -26,14 +26,18 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe'));
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid", "int");
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
//$result = restrictedArea($user, 'salaries', '', '', '');
|
||||
|
||||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
@ -41,7 +45,9 @@ $rowid = GETPOST("rowid", 'alpha');
|
||||
$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;
|
||||
@ -60,8 +66,7 @@ $stripe = new Stripe($db);
|
||||
|
||||
llxHeader('', $langs->trans("StripeChargeList"));
|
||||
|
||||
if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')))
|
||||
{
|
||||
if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
|
||||
$service = 'StripeTest';
|
||||
$servicestatus = '0';
|
||||
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
|
||||
@ -80,11 +85,12 @@ if (!$rowid) {
|
||||
$option = array('limit' => $limit + 1);
|
||||
$num = 0;
|
||||
|
||||
if (GETPOSTISSET('starting_after_'.$page)) $option['starting_after'] = GETPOST('starting_after_'.$page, 'alphanohtml');
|
||||
if (GETPOSTISSET('starting_after_'.$page)) {
|
||||
$option['starting_after'] = GETPOST('starting_after_'.$page, 'alphanohtml');
|
||||
}
|
||||
|
||||
try {
|
||||
if ($stripeacc)
|
||||
{
|
||||
if ($stripeacc) {
|
||||
$list = \Stripe\Charge::all($option, array("stripe_account" => $stripeacc));
|
||||
} else {
|
||||
$list = \Stripe\Charge::all($option);
|
||||
@ -96,7 +102,9 @@ if (!$rowid) {
|
||||
|
||||
$param = '';
|
||||
//if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
$param .= '&starting_after_'.($page + 1).'='.$list->data[($limit - 1)]->id;
|
||||
//$param.='&ending_before_'.($page+1).'='.$list->data[($limit-1)]->id;
|
||||
|
||||
@ -106,7 +114,9 @@ if (!$rowid) {
|
||||
}
|
||||
|
||||
print '<form method="POST" 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">';
|
||||
@ -135,8 +145,7 @@ if (!$rowid) {
|
||||
|
||||
//print $list;
|
||||
$i = 0;
|
||||
foreach ($list->data as $charge)
|
||||
{
|
||||
foreach ($list->data as $charge) {
|
||||
if ($i >= $limit) {
|
||||
break;
|
||||
}
|
||||
@ -179,17 +188,14 @@ if (!$rowid) {
|
||||
// Save into $tmparray all metadata
|
||||
$tmparray = dolExplodeIntoArray($FULLTAG, '.', '=');
|
||||
// Load origin object according to metadata
|
||||
if (!empty($tmparray['CUS']) && $tmparray['CUS'] > 0)
|
||||
{
|
||||
if (!empty($tmparray['CUS']) && $tmparray['CUS'] > 0) {
|
||||
$societestatic->fetch($tmparray['CUS']);
|
||||
} elseif (!empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0)
|
||||
{
|
||||
} elseif (!empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0) {
|
||||
$societestatic->fetch($charge->metadata->dol_thirdparty_id);
|
||||
} else {
|
||||
$societestatic->id = 0;
|
||||
}
|
||||
if (!empty($tmparray['MEM']) && $tmparray['MEM'] > 0)
|
||||
{
|
||||
if (!empty($tmparray['MEM']) && $tmparray['MEM'] > 0) {
|
||||
$memberstatic->fetch($tmparray['MEM']);
|
||||
} else {
|
||||
$memberstatic->id = 0;
|
||||
@ -197,40 +203,41 @@ if (!$rowid) {
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
if (!empty($stripeacc)) $connect = $stripeacc.'/';
|
||||
if (!empty($stripeacc)) {
|
||||
$connect = $stripeacc.'/';
|
||||
}
|
||||
|
||||
// Ref
|
||||
$url = 'https://dashboard.stripe.com/'.$connect.'test/payments/'.$charge->id;
|
||||
if ($servicestatus)
|
||||
{
|
||||
if ($servicestatus) {
|
||||
$url = 'https://dashboard.stripe.com/'.$connect.'payments/'.$charge->id;
|
||||
}
|
||||
print "<td>";
|
||||
print "<a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$charge->id."</a>";
|
||||
if ($charge->payment_intent) print '<br><span class="opacitymedium">'.$charge->payment_intent.'</span>';
|
||||
if ($charge->payment_intent) {
|
||||
print '<br><span class="opacitymedium">'.$charge->payment_intent.'</span>';
|
||||
}
|
||||
print "</td>\n";
|
||||
|
||||
// Stripe customer
|
||||
print "<td>";
|
||||
if (!empty($conf->stripe->enabled) && !empty($stripeacc)) $connect = $stripeacc.'/';
|
||||
if (!empty($conf->stripe->enabled) && !empty($stripeacc)) {
|
||||
$connect = $stripeacc.'/';
|
||||
}
|
||||
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$charge->customer;
|
||||
if ($servicestatus)
|
||||
{
|
||||
if ($servicestatus) {
|
||||
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$charge->customer;
|
||||
}
|
||||
if (!empty($charge->customer))
|
||||
{
|
||||
if (!empty($charge->customer)) {
|
||||
print '<a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').' '.$charge->customer.'</a>';
|
||||
}
|
||||
print "</td>\n";
|
||||
|
||||
// Link
|
||||
print "<td>";
|
||||
if ($societestatic->id > 0)
|
||||
{
|
||||
if ($societestatic->id > 0) {
|
||||
print $societestatic->getNomUrl(1);
|
||||
} elseif ($memberstatic->id > 0)
|
||||
{
|
||||
} elseif ($memberstatic->id > 0) {
|
||||
print $memberstatic->getNomUrl(1);
|
||||
}
|
||||
print "</td>\n";
|
||||
|
||||
@ -71,25 +71,21 @@ class ActionsStripeconnect
|
||||
{
|
||||
global $db, $conf, $user, $langs, $form;
|
||||
|
||||
if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')))
|
||||
{
|
||||
if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
|
||||
$service = 'StripeTest';
|
||||
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
|
||||
} else {
|
||||
$service = 'StripeLive';
|
||||
}
|
||||
|
||||
if (is_array($parameters) && !empty($parameters))
|
||||
{
|
||||
foreach ($parameters as $key=>$value)
|
||||
{
|
||||
if (is_array($parameters) && !empty($parameters)) {
|
||||
foreach ($parameters as $key => $value) {
|
||||
$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (is_object($object) && $object->element == 'societe')
|
||||
{
|
||||
if (is_object($object) && $object->element == 'societe') {
|
||||
$this->resprints .= '<tr><td>';
|
||||
$this->resprints .= '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
$this->resprints .= $langs->trans('StripeCustomer');
|
||||
@ -195,20 +191,16 @@ class ActionsStripeconnect
|
||||
|
||||
$resteapayer = $object->total_ttc - $totalpaye;
|
||||
// Request a direct debit order
|
||||
if ($object->statut > Facture::STATUS_DRAFT && $object->statut < Facture::STATUS_ABANDONED && $object->paye == 0)
|
||||
{
|
||||
if ($object->statut > Facture::STATUS_DRAFT && $object->statut < Facture::STATUS_ABANDONED && $object->paye == 0) {
|
||||
$stripe = new Stripe($this->db);
|
||||
if ($resteapayer > 0)
|
||||
{
|
||||
if ($stripe->getStripeAccount($conf->entity)) // a modifier avec droit stripe
|
||||
{
|
||||
if ($resteapayer > 0) {
|
||||
if ($stripe->getStripeAccount($conf->entity)) { // a modifier avec droit stripe
|
||||
$langs->load("withdrawals");
|
||||
print '<a class="butActionDelete" href="'.dol_buildpath('/stripeconnect/payment.php?facid='.$object->id.'&action=create', 1).'" title="'.dol_escape_htmltag($langs->trans("StripeConnectPay")).'">'.$langs->trans("StripeConnectPay").'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("StripeConnectPay").'</a>';
|
||||
}
|
||||
} elseif ($resteapayer == 0)
|
||||
{
|
||||
} elseif ($resteapayer == 0) {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("StripeConnectPay").'</a>';
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -91,7 +91,9 @@ class Stripe extends CommonObject
|
||||
global $conf;
|
||||
|
||||
$key = '';
|
||||
if ($entity < 0) $entity = $conf->entity;
|
||||
if ($entity < 0) {
|
||||
$entity = $conf->entity;
|
||||
}
|
||||
|
||||
$sql = "SELECT tokenstring";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."oauth_token";
|
||||
@ -155,8 +157,7 @@ class Stripe extends CommonObject
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
if (empty($object->id))
|
||||
{
|
||||
if (empty($object->id)) {
|
||||
dol_syslog("customerStripe is called with the parameter object that is not loaded");
|
||||
return null;
|
||||
}
|
||||
@ -193,8 +194,7 @@ class Stripe extends CommonObject
|
||||
//$customer = \Stripe\Customer::retrieve("$tiers", array("stripe_account" => $key));
|
||||
$customer = \Stripe\Customer::retrieve(array('id'=>"$tiers", 'expand[]'=>'sources'), array("stripe_account" => $key));
|
||||
}
|
||||
} catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
// For exemple, we may have error: 'No such customer: cus_XXXXX; a similar object exists in live mode, but a test mode key was used to make this request.'
|
||||
$this->error = $e->getMessage();
|
||||
}
|
||||
@ -234,13 +234,10 @@ class Stripe extends CommonObject
|
||||
}
|
||||
|
||||
// Create the VAT record in Stripe
|
||||
if (!empty($conf->global->STRIPE_SAVE_TAX_IDS)) // We setup to save Tax info on Stripe side. Warning: This may result in error when saving customer
|
||||
{
|
||||
if (!empty($vatcleaned))
|
||||
{
|
||||
if (!empty($conf->global->STRIPE_SAVE_TAX_IDS)) { // We setup to save Tax info on Stripe side. Warning: This may result in error when saving customer
|
||||
if (!empty($vatcleaned)) {
|
||||
$isineec = isInEEC($object);
|
||||
if ($object->country_code && $isineec)
|
||||
{
|
||||
if ($object->country_code && $isineec) {
|
||||
//$taxids = $customer->allTaxIds($customer->id);
|
||||
$customer->createTaxId($customer->id, array('type'=>'eu_vat', 'value'=>$vatcleaned));
|
||||
}
|
||||
@ -251,12 +248,10 @@ class Stripe extends CommonObject
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
|
||||
$sql .= " VALUES (".$object->id.", '', '".$this->db->escape($customer->id)."', 'stripe', '".$this->db->escape($stripearrayofkeysbyenv[$status]['publishable_key'])."', ".$status.", ".$conf->entity.", '".$this->db->idate(dol_now())."', ".$user->id.")";
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
} catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$this->error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
@ -288,8 +283,7 @@ class Stripe extends CommonObject
|
||||
} else {
|
||||
$stripepaymentmethod = \Stripe\PaymentMethod::retrieve(''.$paymentmethod->id.'', array("stripe_account" => $key));
|
||||
}
|
||||
} catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$this->error = $e->getMessage();
|
||||
}
|
||||
|
||||
@ -329,12 +323,18 @@ class Stripe extends CommonObject
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (empty($status)) $service = 'StripeTest';
|
||||
else $service = 'StripeLive';
|
||||
if (empty($status)) {
|
||||
$service = 'StripeTest';
|
||||
} else {
|
||||
$service = 'StripeLive';
|
||||
}
|
||||
|
||||
$arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
|
||||
if (!in_array($currency_code, $arrayzerounitcurrency)) $stripeamount = $amount * 100;
|
||||
else $stripeamount = $amount;
|
||||
if (!in_array($currency_code, $arrayzerounitcurrency)) {
|
||||
$stripeamount = $amount * 100;
|
||||
} else {
|
||||
$stripeamount = $amount;
|
||||
}
|
||||
|
||||
$fee = $amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE;
|
||||
if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) {
|
||||
@ -350,8 +350,7 @@ class Stripe extends CommonObject
|
||||
|
||||
$paymentintent = null;
|
||||
|
||||
if (is_object($object) && !empty($conf->global->STRIPE_REUSE_EXISTING_INTENT_IF_FOUND))
|
||||
{
|
||||
if (is_object($object) && !empty($conf->global->STRIPE_REUSE_EXISTING_INTENT_IF_FOUND)) {
|
||||
// Warning. If a payment was tried and failed, a payment intent was created.
|
||||
// But if we change something on object to pay (amount or other that does not change the idempotency key), reusing same payment intent is not allowed by Stripe.
|
||||
// Recommended solution is to recreate a new payment intent each time we need one (old one will be automatically closed by Stripe after a delay), Stripe will
|
||||
@ -369,8 +368,7 @@ class Stripe extends CommonObject
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
if ($num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$intent = $obj->ext_payment_id;
|
||||
|
||||
@ -386,8 +384,7 @@ class Stripe extends CommonObject
|
||||
} else {
|
||||
$paymentintent = \Stripe\PaymentIntent::retrieve($intent, array("stripe_account" => $key));
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$error++;
|
||||
$this->error = $e->getMessage();
|
||||
}
|
||||
@ -395,25 +392,35 @@ class Stripe extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($paymentintent))
|
||||
{
|
||||
if (empty($paymentintent)) {
|
||||
// Try to create intent. See https://stripe.com/docs/api/payment_intents/create
|
||||
$ipaddress = getUserRemoteIP();
|
||||
$metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress);
|
||||
if (is_object($object))
|
||||
{
|
||||
if (is_object($object)) {
|
||||
$metadata['dol_type'] = $object->element;
|
||||
$metadata['dol_id'] = $object->id;
|
||||
if (is_object($object->thirdparty) && $object->thirdparty->id > 0) $metadata['dol_thirdparty_id'] = $object->thirdparty->id;
|
||||
if (is_object($object->thirdparty) && $object->thirdparty->id > 0) {
|
||||
$metadata['dol_thirdparty_id'] = $object->thirdparty->id;
|
||||
}
|
||||
}
|
||||
|
||||
// list of payment method types
|
||||
$paymentmethodtypes = array("card");
|
||||
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC())
|
||||
if (!empty($conf->global->STRIPE_BANCONTACT)) $paymentmethodtypes[] = "bancontact";
|
||||
if (!empty($conf->global->STRIPE_IDEAL)) $paymentmethodtypes[] = "ideal";
|
||||
if (!empty($conf->global->STRIPE_GIROPAY)) $paymentmethodtypes[] = "giropay";
|
||||
if (!empty($conf->global->STRIPE_SOFORT)) $paymentmethodtypes[] = "sofort";
|
||||
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) {
|
||||
$paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC())
|
||||
}
|
||||
if (!empty($conf->global->STRIPE_BANCONTACT)) {
|
||||
$paymentmethodtypes[] = "bancontact";
|
||||
}
|
||||
if (!empty($conf->global->STRIPE_IDEAL)) {
|
||||
$paymentmethodtypes[] = "ideal";
|
||||
}
|
||||
if (!empty($conf->global->STRIPE_GIROPAY)) {
|
||||
$paymentmethodtypes[] = "giropay";
|
||||
}
|
||||
if (!empty($conf->global->STRIPE_SOFORT)) {
|
||||
$paymentmethodtypes[] = "sofort";
|
||||
}
|
||||
|
||||
$dataforintent = array(
|
||||
"confirm" => $confirmnow, // Do not confirm immediatly during creation of intent
|
||||
@ -427,32 +434,32 @@ class Stripe extends CommonObject
|
||||
"setup_future_usage" => "on_session",
|
||||
"metadata" => $metadata
|
||||
);
|
||||
if (!is_null($customer)) $dataforintent["customer"] = $customer;
|
||||
if (!is_null($customer)) {
|
||||
$dataforintent["customer"] = $customer;
|
||||
}
|
||||
// payment_method =
|
||||
// payment_method_types = array('card')
|
||||
//var_dump($dataforintent);
|
||||
if ($off_session)
|
||||
{
|
||||
if ($off_session) {
|
||||
unset($dataforintent['setup_future_usage']);
|
||||
// We can't use both "setup_future_usage" = "off_session" and "off_session" = true.
|
||||
// Because $off_session parameter is dedicated to create paymentintent off_line (and not future payment), we need to use "off_session" = true.
|
||||
//$dataforintent["setup_future_usage"] = "off_session";
|
||||
$dataforintent["off_session"] = true;
|
||||
}
|
||||
if (!empty($conf->global->STRIPE_GIROPAY)) unset($dataforintent['setup_future_usage']);
|
||||
if (!empty($conf->global->STRIPE_GIROPAY)) {
|
||||
unset($dataforintent['setup_future_usage']);
|
||||
}
|
||||
|
||||
if (!is_null($payment_method))
|
||||
{
|
||||
if (!is_null($payment_method)) {
|
||||
$dataforintent["payment_method"] = $payment_method;
|
||||
$description .= ' - '.$payment_method;
|
||||
}
|
||||
|
||||
if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0)
|
||||
{
|
||||
if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) {
|
||||
$dataforintent["application_fee_amount"] = $stripefee;
|
||||
}
|
||||
if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email)
|
||||
{
|
||||
if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email) {
|
||||
$dataforintent["receipt_email"] = $object->thirdparty->email;
|
||||
}
|
||||
|
||||
@ -475,8 +482,7 @@ class Stripe extends CommonObject
|
||||
$paymentintent = \Stripe\PaymentIntent::create($dataforintent, $arrayofoptions);
|
||||
|
||||
// Store the payment intent
|
||||
if (is_object($object))
|
||||
{
|
||||
if (is_object($object)) {
|
||||
$paymentintentalreadyexists = 0;
|
||||
// Check that payment intent $paymentintent->id is not already recorded.
|
||||
$sql = "SELECT pi.rowid";
|
||||
@ -489,22 +495,23 @@ class Stripe extends CommonObject
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
if ($num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj) $paymentintentalreadyexists++;
|
||||
if ($obj) {
|
||||
$paymentintentalreadyexists++;
|
||||
}
|
||||
}
|
||||
} else dol_print_error($this->db);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
// If not, we create it.
|
||||
if (!$paymentintentalreadyexists)
|
||||
{
|
||||
if (!$paymentintentalreadyexists) {
|
||||
$now = dol_now();
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site, amount)";
|
||||
$sql .= " VALUES ('".$this->db->idate($now)."', ".$user->id.", '".$this->db->escape($paymentintent->id)."', ".$object->id.", '".$this->db->escape($object->element)."', ".$conf->entity.", '".$this->db->escape($service)."', ".$amount.")";
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::PaymentIntent failed to insert paymentintent with id=".$paymentintent->id." into database.");
|
||||
@ -513,20 +520,18 @@ class Stripe extends CommonObject
|
||||
} else {
|
||||
$_SESSION["stripe_payment_intent"] = $paymentintent;
|
||||
}
|
||||
} catch (Stripe\Error\Card $e)
|
||||
{
|
||||
} catch (Stripe\Error\Card $e) {
|
||||
$error++;
|
||||
$this->error = $e->getMessage();
|
||||
$this->code = $e->getStripeCode();
|
||||
$this->declinecode = $e->getDeclineCode();
|
||||
} catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
/*var_dump($dataforintent);
|
||||
var_dump($description);
|
||||
var_dump($key);
|
||||
var_dump($paymentintent);
|
||||
var_dump($e->getMessage());
|
||||
var_dump($e);*/
|
||||
var_dump($description);
|
||||
var_dump($key);
|
||||
var_dump($paymentintent);
|
||||
var_dump($e->getMessage());
|
||||
var_dump($e);*/
|
||||
$error++;
|
||||
$this->error = $e->getMessage();
|
||||
$this->code = '';
|
||||
@ -570,29 +575,40 @@ class Stripe extends CommonObject
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (empty($status)) $service = 'StripeTest';
|
||||
else $service = 'StripeLive';
|
||||
if (empty($status)) {
|
||||
$service = 'StripeTest';
|
||||
} else {
|
||||
$service = 'StripeLive';
|
||||
}
|
||||
|
||||
$setupintent = null;
|
||||
|
||||
if (empty($setupintent))
|
||||
{
|
||||
if (empty($setupintent)) {
|
||||
$ipaddress = getUserRemoteIP();
|
||||
$metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress);
|
||||
if (is_object($object))
|
||||
{
|
||||
if (is_object($object)) {
|
||||
$metadata['dol_type'] = $object->element;
|
||||
$metadata['dol_id'] = $object->id;
|
||||
if (is_object($object->thirdparty) && $object->thirdparty->id > 0) $metadata['dol_thirdparty_id'] = $object->thirdparty->id;
|
||||
if (is_object($object->thirdparty) && $object->thirdparty->id > 0) {
|
||||
$metadata['dol_thirdparty_id'] = $object->thirdparty->id;
|
||||
}
|
||||
}
|
||||
|
||||
// list of payment method types
|
||||
$paymentmethodtypes = array("card");
|
||||
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC())
|
||||
if (!empty($conf->global->STRIPE_BANCONTACT)) $paymentmethodtypes[] = "bancontact";
|
||||
if (!empty($conf->global->STRIPE_IDEAL)) $paymentmethodtypes[] = "ideal";
|
||||
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) {
|
||||
$paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC())
|
||||
}
|
||||
if (!empty($conf->global->STRIPE_BANCONTACT)) {
|
||||
$paymentmethodtypes[] = "bancontact";
|
||||
}
|
||||
if (!empty($conf->global->STRIPE_IDEAL)) {
|
||||
$paymentmethodtypes[] = "ideal";
|
||||
}
|
||||
// Giropay not possible for setup intent
|
||||
if (!empty($conf->global->STRIPE_SOFORT)) $paymentmethodtypes[] = "sofort";
|
||||
if (!empty($conf->global->STRIPE_SOFORT)) {
|
||||
$paymentmethodtypes[] = "sofort";
|
||||
}
|
||||
|
||||
$dataforintent = array(
|
||||
"confirm" => $confirmnow, // Do not confirm immediatly during creation of intent
|
||||
@ -600,14 +616,17 @@ class Stripe extends CommonObject
|
||||
"usage" => "off_session",
|
||||
"metadata" => $metadata
|
||||
);
|
||||
if (!is_null($customer)) $dataforintent["customer"] = $customer;
|
||||
if (!is_null($description)) $dataforintent["description"] = $description;
|
||||
if (!is_null($customer)) {
|
||||
$dataforintent["customer"] = $customer;
|
||||
}
|
||||
if (!is_null($description)) {
|
||||
$dataforintent["description"] = $description;
|
||||
}
|
||||
// payment_method =
|
||||
// payment_method_types = array('card')
|
||||
//var_dump($dataforintent);
|
||||
|
||||
if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email)
|
||||
{
|
||||
if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email) {
|
||||
$dataforintent["receipt_email"] = $object->thirdparty->email;
|
||||
}
|
||||
|
||||
@ -670,8 +689,7 @@ class Stripe extends CommonObject
|
||||
{
|
||||
$_SESSION["stripe_setup_intent"] = $setupintent;
|
||||
}*/
|
||||
} catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
/*var_dump($dataforintent);
|
||||
var_dump($description);
|
||||
var_dump($key);
|
||||
@ -682,8 +700,7 @@ class Stripe extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
dol_syslog("getSetupIntent ".(is_object($setupintent) ? $setupintent->id : ''), LOG_INFO, -1);
|
||||
return $setupintent;
|
||||
} else {
|
||||
@ -718,24 +735,20 @@ class Stripe extends CommonObject
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
if ($num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$cardref = $obj->stripe_card_ref;
|
||||
dol_syslog(get_class($this)."::cardStripe cardref=".$cardref);
|
||||
if ($cardref)
|
||||
{
|
||||
if ($cardref) {
|
||||
try {
|
||||
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
||||
if (!preg_match('/^pm_/', $cardref) && !empty($cu->sources))
|
||||
{
|
||||
if (!preg_match('/^pm_/', $cardref) && !empty($cu->sources)) {
|
||||
$card = $cu->sources->retrieve($cardref);
|
||||
} else {
|
||||
$card = \Stripe\PaymentMethod::retrieve($cardref);
|
||||
}
|
||||
} else {
|
||||
if (!preg_match('/^pm_/', $cardref) && !empty($cu->sources))
|
||||
{
|
||||
if (!preg_match('/^pm_/', $cardref) && !empty($cu->sources)) {
|
||||
//$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided
|
||||
$card = $cu->sources->retrieve($cardref);
|
||||
} else {
|
||||
@ -743,13 +756,11 @@ class Stripe extends CommonObject
|
||||
$card = \Stripe\PaymentMethod::retrieve($cardref);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
}
|
||||
} elseif ($createifnotlinkedtostripe)
|
||||
{
|
||||
} elseif ($createifnotlinkedtostripe) {
|
||||
$exp_date_month = $obj->exp_date_month;
|
||||
$exp_date_year = $obj->exp_date_year;
|
||||
$number = $obj->number;
|
||||
@ -767,20 +778,19 @@ class Stripe extends CommonObject
|
||||
//var_dump($a);var_dump($stripeacc);exit;
|
||||
try {
|
||||
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
||||
if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
|
||||
{
|
||||
if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
|
||||
dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard));
|
||||
$card = $cu->sources->create($dataforcard);
|
||||
if (!$card)
|
||||
{
|
||||
if (!$card) {
|
||||
$this->error = 'Creation of card on Stripe has failed';
|
||||
}
|
||||
} else {
|
||||
$connect = '';
|
||||
if (!empty($stripeacc)) $connect = $stripeacc.'/';
|
||||
if (!empty($stripeacc)) {
|
||||
$connect = $stripeacc.'/';
|
||||
}
|
||||
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$cu->id;
|
||||
if ($status)
|
||||
{
|
||||
if ($status) {
|
||||
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id;
|
||||
}
|
||||
$urtoswitchonstripe = ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').'</a>';
|
||||
@ -789,20 +799,19 @@ class Stripe extends CommonObject
|
||||
$this->error = $langs->trans('CreationOfPaymentModeMustBeDoneFromStripeInterface', $urtoswitchonstripe);
|
||||
}
|
||||
} else {
|
||||
if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
|
||||
{
|
||||
if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
|
||||
dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard));
|
||||
$card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc));
|
||||
if (!$card)
|
||||
{
|
||||
if (!$card) {
|
||||
$this->error = 'Creation of card on Stripe has failed';
|
||||
}
|
||||
} else {
|
||||
$connect = '';
|
||||
if (!empty($stripeacc)) $connect = $stripeacc.'/';
|
||||
if (!empty($stripeacc)) {
|
||||
$connect = $stripeacc.'/';
|
||||
}
|
||||
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$cu->id;
|
||||
if ($status)
|
||||
{
|
||||
if ($status) {
|
||||
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id;
|
||||
}
|
||||
$urtoswitchonstripe = ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').'</a>';
|
||||
@ -812,8 +821,7 @@ class Stripe extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if ($card)
|
||||
{
|
||||
if ($card) {
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib";
|
||||
$sql .= " SET stripe_card_ref = '".$this->db->escape($card->id)."', card_type = '".$this->db->escape($card->brand)."',";
|
||||
$sql .= " country_code = '".$this->db->escape($card->country)."',";
|
||||
@ -821,13 +829,11 @@ class Stripe extends CommonObject
|
||||
$sql .= " WHERE rowid = ".$object->id;
|
||||
$sql .= " AND type = 'card'";
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
} catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
}
|
||||
@ -862,8 +868,11 @@ class Stripe extends CommonObject
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (empty($status)) $service = 'StripeTest';
|
||||
else $service = 'StripeLive';
|
||||
if (empty($status)) {
|
||||
$service = 'StripeTest';
|
||||
} else {
|
||||
$service = 'StripeLive';
|
||||
}
|
||||
|
||||
$sql = "SELECT sa.key_account as key_account, sa.fk_soc, sa.entity";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_account as sa";
|
||||
@ -885,11 +894,16 @@ class Stripe extends CommonObject
|
||||
}
|
||||
|
||||
$arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
|
||||
if (!in_array($currency, $arrayzerounitcurrency)) $stripeamount = $amount * 100;
|
||||
else $stripeamount = $amount;
|
||||
if (!in_array($currency, $arrayzerounitcurrency)) {
|
||||
$stripeamount = $amount * 100;
|
||||
} else {
|
||||
$stripeamount = $amount;
|
||||
}
|
||||
|
||||
$societe = new Societe($this->db);
|
||||
if ($key > 0) $societe->fetch($key);
|
||||
if ($key > 0) {
|
||||
$societe->fetch($key);
|
||||
}
|
||||
|
||||
$description = "";
|
||||
$ref = "";
|
||||
@ -922,10 +936,8 @@ class Stripe extends CommonObject
|
||||
global $stripearrayofkeysbyenv;
|
||||
\Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']);
|
||||
|
||||
if (empty($conf->stripeconnect->enabled)) // With a common Stripe account
|
||||
{
|
||||
if (preg_match('/pm_/i', $source))
|
||||
{
|
||||
if (empty($conf->stripeconnect->enabled)) { // With a common Stripe account
|
||||
if (preg_match('/pm_/i', $source)) {
|
||||
$stripecard = $source;
|
||||
$amountstripe = $stripeamount;
|
||||
$FULLTAG = 'PFBO'; // Payment From Back Office
|
||||
@ -942,8 +954,7 @@ class Stripe extends CommonObject
|
||||
$paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $invoice, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1);
|
||||
|
||||
$charge = new stdClass();
|
||||
if ($paymentintent->status == 'succeeded')
|
||||
{
|
||||
if ($paymentintent->status == 'succeeded') {
|
||||
$charge->status = 'ok';
|
||||
} else {
|
||||
$charge->status = 'failed';
|
||||
@ -954,8 +965,7 @@ class Stripe extends CommonObject
|
||||
$stripefailuremessage = $stripe->error;
|
||||
$stripefailuredeclinecode = $stripe->declinecode;
|
||||
}
|
||||
} elseif (preg_match('/acct_/i', $source))
|
||||
{
|
||||
} elseif (preg_match('/acct_/i', $source)) {
|
||||
$charge = \Stripe\Charge::create(array(
|
||||
"amount" => "$stripeamount",
|
||||
"currency" => "$currency",
|
||||
@ -977,8 +987,7 @@ class Stripe extends CommonObject
|
||||
"customer" => "$customer"
|
||||
);
|
||||
|
||||
if ($societe->email && $usethirdpartyemailforreceiptemail)
|
||||
{
|
||||
if ($societe->email && $usethirdpartyemailforreceiptemail) {
|
||||
$paymentarray["receipt_email"] = $societe->email;
|
||||
}
|
||||
|
||||
@ -993,8 +1002,11 @@ class Stripe extends CommonObject
|
||||
$fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL;
|
||||
}
|
||||
|
||||
if (!in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100);
|
||||
else $stripefee = round($fee);
|
||||
if (!in_array($currency, $arrayzerounitcurrency)) {
|
||||
$stripefee = round($fee * 100);
|
||||
} else {
|
||||
$stripefee = round($fee);
|
||||
}
|
||||
|
||||
$paymentarray = array(
|
||||
"amount" => "$stripeamount",
|
||||
@ -1006,17 +1018,14 @@ class Stripe extends CommonObject
|
||||
"source" => "$source",
|
||||
"customer" => "$customer"
|
||||
);
|
||||
if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0)
|
||||
{
|
||||
if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) {
|
||||
$paymentarray["application_fee_amount"] = $stripefee;
|
||||
}
|
||||
if ($societe->email && $usethirdpartyemailforreceiptemail)
|
||||
{
|
||||
if ($societe->email && $usethirdpartyemailforreceiptemail) {
|
||||
$paymentarray["receipt_email"] = $societe->email;
|
||||
}
|
||||
|
||||
if (preg_match('/pm_/i', $source))
|
||||
{
|
||||
if (preg_match('/pm_/i', $source)) {
|
||||
$stripecard = $source;
|
||||
$amountstripe = $stripeamount;
|
||||
$FULLTAG = 'PFBO'; // Payment From Back Office
|
||||
@ -1033,8 +1042,7 @@ class Stripe extends CommonObject
|
||||
$paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $invoice, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1);
|
||||
|
||||
$charge = new stdClass();
|
||||
if ($paymentintent->status == 'succeeded')
|
||||
{
|
||||
if ($paymentintent->status == 'succeeded') {
|
||||
$charge->status = 'ok';
|
||||
$charge->id = $paymentintent->id;
|
||||
} else {
|
||||
@ -1047,13 +1055,13 @@ class Stripe extends CommonObject
|
||||
$charge = \Stripe\Charge::create($paymentarray, array("idempotency_key" => "$description", "stripe_account" => "$account"));
|
||||
}
|
||||
}
|
||||
if (isset($charge->id)) {}
|
||||
if (isset($charge->id)) {
|
||||
}
|
||||
|
||||
$return->statut = 'success';
|
||||
$return->id = $charge->id;
|
||||
|
||||
if (preg_match('/pm_/i', $source))
|
||||
{
|
||||
if (preg_match('/pm_/i', $source)) {
|
||||
$return->message = 'Payment retrieved by card status = '.$charge->status;
|
||||
} else {
|
||||
if ($charge->source->type == 'card') {
|
||||
|
||||
@ -44,8 +44,7 @@ $stripearrayofkeysbyenv = array(
|
||||
);
|
||||
|
||||
$stripearrayofkeys = array();
|
||||
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))
|
||||
{
|
||||
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) {
|
||||
$stripearrayofkeys = $stripearrayofkeysbyenv[0]; // Test
|
||||
} else {
|
||||
$stripearrayofkeys = $stripearrayofkeysbyenv[1]; // Live
|
||||
|
||||
@ -67,52 +67,53 @@ function html_print_stripe_footer($fromcompany, $langs)
|
||||
|
||||
// Juridical status
|
||||
$line1 = "";
|
||||
if ($fromcompany->forme_juridique_code)
|
||||
{
|
||||
if ($fromcompany->forme_juridique_code) {
|
||||
$line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code);
|
||||
}
|
||||
// Capital
|
||||
if ($fromcompany->capital)
|
||||
{
|
||||
if ($fromcompany->capital) {
|
||||
$line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency);
|
||||
}
|
||||
|
||||
$reg = array();
|
||||
|
||||
// Prof Id 1
|
||||
if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2))
|
||||
{
|
||||
if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) {
|
||||
$field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code);
|
||||
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
|
||||
if (preg_match('/\((.*)\)/i', $field, $reg)) {
|
||||
$field = $reg[1];
|
||||
}
|
||||
$line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1;
|
||||
}
|
||||
// Prof Id 2
|
||||
if ($fromcompany->idprof2)
|
||||
{
|
||||
if ($fromcompany->idprof2) {
|
||||
$field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code);
|
||||
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
|
||||
if (preg_match('/\((.*)\)/i', $field, $reg)) {
|
||||
$field = $reg[1];
|
||||
}
|
||||
$line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2;
|
||||
}
|
||||
|
||||
// Second line of company infos
|
||||
$line2 = "";
|
||||
// Prof Id 3
|
||||
if ($fromcompany->idprof3)
|
||||
{
|
||||
if ($fromcompany->idprof3) {
|
||||
$field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code);
|
||||
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
|
||||
if (preg_match('/\((.*)\)/i', $field, $reg)) {
|
||||
$field = $reg[1];
|
||||
}
|
||||
$line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3;
|
||||
}
|
||||
// Prof Id 4
|
||||
if ($fromcompany->idprof4)
|
||||
{
|
||||
if ($fromcompany->idprof4) {
|
||||
$field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code);
|
||||
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
|
||||
if (preg_match('/\((.*)\)/i', $field, $reg)) {
|
||||
$field = $reg[1];
|
||||
}
|
||||
$line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4;
|
||||
}
|
||||
// IntraCommunautary VAT
|
||||
if ($fromcompany->tva_intra != '')
|
||||
{
|
||||
if ($fromcompany->tva_intra != '') {
|
||||
$line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user