Fix delete of member

This commit is contained in:
Laurent Destailleur 2017-06-09 17:02:05 +02:00
parent def784a5fe
commit 3347316d3c
7 changed files with 177 additions and 176 deletions

View File

@ -182,7 +182,7 @@ abstract class ActionsAdherentCardCommon
$this->object->old_name = $_POST["old_name"]; $this->object->old_name = $_POST["old_name"];
$this->object->old_firstname = $_POST["old_firstname"]; $this->object->old_firstname = $_POST["old_firstname"];
$result = $this->object->delete(); $result = $this->object->delete(0, $user, 0);
if ($result > 0) if ($result > 0)
{ {
header("Location: list.php"); header("Location: list.php");
@ -424,7 +424,7 @@ abstract class ActionsAdherentCardCommon
if ($resql) if ($resql)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->object->country_code = $obj->code; $this->object->country_code = $obj->code;
$this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
} }

View File

@ -585,7 +585,7 @@ if (empty($reshook))
if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
{ {
$result=$object->delete($id); $result=$object->delete($id, $user);
if ($result > 0) if ($result > 0)
{ {
if (! empty($backtopage)) if (! empty($backtopage))

View File

@ -705,11 +705,13 @@ class Adherent extends CommonObject
* Fonction qui supprime l'adherent et les donnees associees * Fonction qui supprime l'adherent et les donnees associees
* *
* @param int $rowid Id of member to delete * @param int $rowid Id of member to delete
* @param User $user User object
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, 0=nothing to do, >0 if OK * @return int <0 if KO, 0=nothing to do, >0 if OK
*/ */
function delete($rowid) function delete($rowid, $user, $notrigger=0)
{ {
global $conf, $langs, $user; global $conf, $langs;
$result = 0; $result = 0;
$error=0; $error=0;
@ -720,6 +722,14 @@ class Adherent extends CommonObject
$this->db->begin(); $this->db->begin();
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('MEMBER_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
}
// Remove category // Remove category
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
@ -787,16 +797,6 @@ class Adherent extends CommonObject
} }
} }
if (! $error)
{
// Call trigger
$result=$this->call_trigger('MEMBER_DELETE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
@ -1592,7 +1592,7 @@ class Adherent extends CommonObject
global $conf, $langs; global $conf, $langs;
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0;
$result=''; $label=''; $result=''; $label='';
$link=''; $linkstart=''; $linkend=''; $link=''; $linkstart=''; $linkend='';
@ -1602,7 +1602,7 @@ class Adherent extends CommonObject
$label.= Form::showphoto('memberphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1); $label.= Form::showphoto('memberphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1);
$label.= '</div><div style="clear: both;"></div>'; $label.= '</div><div style="clear: both;"></div>';
} }
$label.= '<div class="centpercent">'; $label.= '<div class="centpercent">';
$label.= '<u>' . $langs->trans("Member") . '</u>'; $label.= '<u>' . $langs->trans("Member") . '</u>';
if (! empty($this->ref)) if (! empty($this->ref))
@ -1610,7 +1610,7 @@ class Adherent extends CommonObject
if (! empty($this->firstname) || ! empty($this->lastname)) if (! empty($this->firstname) || ! empty($this->lastname))
$label.= '<br><b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs); $label.= '<br><b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs);
$label.='</div>'; $label.='</div>';
if ($option == 'card' || $option == 'category') if ($option == 'card' || $option == 'category')
{ {
$link = '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id.'"'; $link = '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id.'"';
@ -1619,7 +1619,7 @@ class Adherent extends CommonObject
{ {
$link = '<a href="'.DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$this->id.'"'; $link = '<a href="'.DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$this->id.'"';
} }
$linkclose=""; $linkclose="";
if (empty($notooltip)) if (empty($notooltip))
{ {
@ -1632,10 +1632,10 @@ class Adherent extends CommonObject
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.= ' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; $linkclose.= ' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
} }
$link.=$linkclose.'>'; $link.=$linkclose.'>';
$linkend='</a>'; $linkend='</a>';
//if ($withpictoimg == -1) $result.='<div class="nowrap">'; //if ($withpictoimg == -1) $result.='<div class="nowrap">';
$result.=$link; $result.=$link;
if ($withpictoimg) if ($withpictoimg)
@ -1658,7 +1658,7 @@ class Adherent extends CommonObject
} }
$result.=$linkend; $result.=$linkend;
//if ($withpictoimg == -1) $result.='</div>'; //if ($withpictoimg == -1) $result.='</div>';
return $result; return $result;
} }
@ -1883,7 +1883,7 @@ class Adherent extends CommonObject
$modele = $conf->global->ADHERENT_ADDON_PDF; $modele = $conf->global->ADHERENT_ADDON_PDF;
} }
} }
$modelpath = "core/modules/member/doc/"; $modelpath = "core/modules/member/doc/";
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);

View File

@ -250,11 +250,7 @@ class Members extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
// The Adherent::delete() method uses the global variable $user. if (! $member->delete($member->id, DolibarrApiAccess::$user)) {
global $user;
$user = DolibarrApiAccess::$user;
if (! $member->delete($member->id)) {
throw new RestException(401,'error when deleting member'); throw new RestException(401,'error when deleting member');
} }

View File

@ -31,13 +31,17 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
$langs->load("members"); $langs->loadLangs(array("members","companies"));
$langs->load("companies");
$action=GETPOST('action','aZ09');
$massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
// Security check // Security check
$result=restrictedArea($user,'adherent'); $result=restrictedArea($user,'adherent');
$action=GETPOST('action','aZ09');
$filter=GETPOST("filter"); $filter=GETPOST("filter");
$statut=GETPOST("statut"); $statut=GETPOST("statut");
$search=GETPOST("search"); $search=GETPOST("search");
@ -53,7 +57,7 @@ $search_country=GETPOST("search_country");
$search_phone=GETPOST("search_phone"); $search_phone=GETPOST("search_phone");
$search_phone_perso=GETPOST("search_phone_perso"); $search_phone_perso=GETPOST("search_phone_perso");
$search_phone_mobile=GETPOST("search_phone_mobile"); $search_phone_mobile=GETPOST("search_phone_mobile");
$type=GETPOST("type"); $search_type=GETPOST("search_type");
$search_email=GETPOST("search_email"); $search_email=GETPOST("search_email");
$search_categ = GETPOST("search_categ",'int'); $search_categ = GETPOST("search_categ",'int');
$catid = GETPOST("catid",'int'); $catid = GETPOST("catid",'int');
@ -155,7 +159,7 @@ if (empty($reshook))
$search_firstname=""; $search_firstname="";
$search_login=""; $search_login="";
$search_company=""; $search_company="";
$type=""; $search_type="";
$search_email=""; $search_email="";
$search_address=""; $search_address="";
$search_zip=""; $search_zip="";
@ -173,6 +177,14 @@ if (empty($reshook))
$toselect=''; $toselect='';
$search_array_options=array(); $search_array_options=array();
} }
// Mass actions
$objectclass='Adherent';
$objectlabel='Members';
$permtoread = $user->rights->adherent->lire;
$permtodelete = $user->rights->adherent->supprimer;
$uploaddir = $conf->adherent->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
} }
@ -193,8 +205,8 @@ $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.pu
$sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; $sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,";
$sql.= " t.libelle as type, t.subscription,"; $sql.= " t.libelle as type, t.subscription,";
$sql.= " state.code_departement as state_code, state.nom as state_name"; $sql.= " state.code_departement as state_code, state.nom as state_name";
// Add fields for extrafields // Add fields from extrafields
foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks // Add fields from hooks
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
@ -212,7 +224,7 @@ if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_ca
if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL"; if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
$sql.= " AND d.entity IN (".getEntity('adherent').")"; $sql.= " AND d.entity IN (".getEntity('adherent').")";
if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall); if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall);
if ($type > 0) $sql.=" AND t.rowid=".$db->escape($type); if ($search_type > 0) $sql.=" AND t.rowid=".$db->escape($search_type);
if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules
if ($search_ref) if ($search_ref)
{ {
@ -298,10 +310,10 @@ elseif ($action == 'search')
$titre=$langs->trans("MembersListQualified"); $titre=$langs->trans("MembersListQualified");
} }
if ($type > 0) if ($search_type > 0)
{ {
$membertype=new AdherentType($db); $membertype=new AdherentType($db);
$result=$membertype->fetch(GETPOST("type")); $result=$membertype->fetch(GETPOST("type",'int'));
$titre.=" (".$membertype->libelle.")"; $titre.=" (".$membertype->libelle.")";
} }
@ -326,7 +338,7 @@ if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone);
if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso); if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso);
if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile); if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile);
if ($filter) $param.="&filter=".urlencode($filter); if ($filter) $param.="&filter=".urlencode($filter);
if ($type > 0) $param.="&type=".urlencode($type); if ($search_type > 0) $param.="&search_type=".urlencode($search_type);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
// Add $param from extra fields // Add $param from extra fields
foreach ($search_array_options as $key => $val) foreach ($search_array_options as $key => $val)
@ -346,7 +358,7 @@ if ($user->rights->adherent->supprimer) $arrayofmassactions['delete']=$langs->tr
//if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); //if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; 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="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
@ -403,32 +415,32 @@ if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
} }
// Ref // Ref
if (! empty($arrayfields['d.ref']['checked'])) if (! empty($arrayfields['d.ref']['checked']))
{ {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>'; print '</td>';
} }
if (! empty($arrayfields['d.firstname']['checked'])) if (! empty($arrayfields['d.firstname']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>'; print '<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>';
} }
if (! empty($arrayfields['d.lastname']['checked'])) if (! empty($arrayfields['d.lastname']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>'; print '<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
} }
if (! empty($arrayfields['d.company']['checked'])) if (! empty($arrayfields['d.company']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth50" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"></td>'; print '<input class="flat maxwidth50" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"></td>';
} }
if (! empty($arrayfields['d.login']['checked'])) if (! empty($arrayfields['d.login']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth50" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>'; print '<input class="flat maxwidth50" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
@ -440,26 +452,26 @@ if (! empty($arrayfields['d.morphy']['checked']))
print '</td>'; print '</td>';
} }
if (! empty($arrayfields['t.libelle']['checked'])) if (! empty($arrayfields['t.libelle']['checked']))
{ {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
$listetype=$membertypestatic->liste_array(); $listetype=$membertypestatic->liste_array();
print $form->selectarray("type", $listetype, $type, 1, 0, 0, '', 0, 32); print $form->selectarray("search_type", $listetype, $type, 1, 0, 0, '', 0, 32);
print '</td>'; print '</td>';
} }
if (! empty($arrayfields['d.address']['checked'])) if (! empty($arrayfields['d.address']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth50" type="text" name="search_address" value="'.$search_address.'"></td>'; print '<input class="flat maxwidth50" type="text" name="search_address" value="'.$search_address.'"></td>';
} }
if (! empty($arrayfields['d.zip']['checked'])) if (! empty($arrayfields['d.zip']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>'; print '<input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>';
} }
if (! empty($arrayfields['d.town']['checked'])) if (! empty($arrayfields['d.town']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>'; print '<input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>';
@ -479,31 +491,31 @@ if (! empty($arrayfields['country.code_iso']['checked']))
print '</td>'; print '</td>';
} }
// Phone pro // Phone pro
if (! empty($arrayfields['d.phone']['checked'])) if (! empty($arrayfields['d.phone']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth50" type="text" name="search_phone" value="'.$search_phone.'"></td>'; print '<input class="flat maxwidth50" type="text" name="search_phone" value="'.$search_phone.'"></td>';
} }
// Phone perso // Phone perso
if (! empty($arrayfields['d.phone_perso']['checked'])) if (! empty($arrayfields['d.phone_perso']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth50" type="text" name="search_phone_perso" value="'.$search_phone_perso.'"></td>'; print '<input class="flat maxwidth50" type="text" name="search_phone_perso" value="'.$search_phone_perso.'"></td>';
} }
// Phone mobile // Phone mobile
if (! empty($arrayfields['d.phone_mobile']['checked'])) if (! empty($arrayfields['d.phone_mobile']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth50" type="text" name="search_phone_mobile" value="'.$search_phone_mobile.'"></td>'; print '<input class="flat maxwidth50" type="text" name="search_phone_mobile" value="'.$search_phone_mobile.'"></td>';
} }
// Email // Email
if (! empty($arrayfields['d.email']['checked'])) if (! empty($arrayfields['d.email']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth50" type="text" name="search_email" value="'.$search_email.'"></td>'; print '<input class="flat maxwidth50" type="text" name="search_email" value="'.$search_email.'"></td>';
} }
if (! empty($arrayfields['d.datefin']['checked'])) if (! empty($arrayfields['d.datefin']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '</td>'; print '</td>';
@ -626,7 +638,7 @@ while ($i < min($num, $limit))
$memberstatic->datefin= $datefin; $memberstatic->datefin= $datefin;
$memberstatic->socid = $obj->fk_soc; $memberstatic->socid = $obj->fk_soc;
$memberstatic->photo = $obj->photo; $memberstatic->photo = $obj->photo;
if (! empty($obj->fk_soc)) { if (! empty($obj->fk_soc)) {
$memberstatic->fetch_thirdparty(); $memberstatic->fetch_thirdparty();
$companyname=$memberstatic->thirdparty->name; $companyname=$memberstatic->thirdparty->name;
@ -635,52 +647,52 @@ while ($i < min($num, $limit))
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
{ {
print '<td align="center">'.($i+1).'</td>'; print '<td align="center">'.($i+1).'</td>';
} }
// Ref // Ref
if (! empty($arrayfields['d.ref']['checked'])) if (! empty($arrayfields['d.ref']['checked']))
{ {
print "<td>"; print "<td>";
print $memberstatic->getNomUrl(-1, 0, 'card', 'ref'); print $memberstatic->getNomUrl(-1, 0, 'card', 'ref');
print "</td>\n"; print "</td>\n";
} }
// Firstname // Firstname
if (! empty($arrayfields['d.firstname']['checked'])) if (! empty($arrayfields['d.firstname']['checked']))
{ {
print "<td>"; print "<td>";
print $obj->firstname; print $obj->firstname;
print "</td>\n"; print "</td>\n";
} }
// Lastname // Lastname
if (! empty($arrayfields['d.lastname']['checked'])) if (! empty($arrayfields['d.lastname']['checked']))
{ {
print "<td>"; print "<td>";
print $obj->lastname; print $obj->lastname;
print "</td>\n"; print "</td>\n";
} }
// Company // Company
if (! empty($arrayfields['d.company']['checked'])) if (! empty($arrayfields['d.company']['checked']))
{ {
print "<td>"; print "<td>";
print $companyname; print $companyname;
print "</td>\n"; print "</td>\n";
} }
// Login // Login
if (! empty($arrayfields['d.login']['checked'])) if (! empty($arrayfields['d.login']['checked']))
{ {
print "<td>".$obj->login."</td>\n"; print "<td>".$obj->login."</td>\n";
} }
// Moral/Physique // Moral/Physique
if (! empty($arrayfields['d.morphy']['checked'])) if (! empty($arrayfields['d.morphy']['checked']))
{ {
print "<td>".$memberstatic->getmorphylib($obj->morphy)."</td>\n"; print "<td>".$memberstatic->getmorphylib($obj->morphy)."</td>\n";
} }
// Type label // Type label
if (! empty($arrayfields['t.libelle']['checked'])) if (! empty($arrayfields['t.libelle']['checked']))
{ {
$membertypestatic->id=$obj->type_id; $membertypestatic->id=$obj->type_id;
$membertypestatic->libelle=$obj->type; $membertypestatic->libelle=$obj->type;
@ -727,7 +739,7 @@ while ($i < min($num, $limit))
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Phone pro // Phone pro
if (! empty($arrayfields['d.phone']['checked'])) if (! empty($arrayfields['d.phone']['checked']))
{ {
print '<td class="nocellnopadd">'; print '<td class="nocellnopadd">';
print $obj->phone; print $obj->phone;
@ -735,7 +747,7 @@ while ($i < min($num, $limit))
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Phone perso // Phone perso
if (! empty($arrayfields['d.phone_perso']['checked'])) if (! empty($arrayfields['d.phone_perso']['checked']))
{ {
print '<td class="nocellnopadd">'; print '<td class="nocellnopadd">';
print $obj->phone_perso; print $obj->phone_perso;
@ -743,7 +755,7 @@ while ($i < min($num, $limit))
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Phone mobile // Phone mobile
if (! empty($arrayfields['d.phone_mobile']['checked'])) if (! empty($arrayfields['d.phone_mobile']['checked']))
{ {
print '<td class="nocellnopadd">'; print '<td class="nocellnopadd">';
print $obj->phone_mobile; print $obj->phone_mobile;
@ -756,7 +768,7 @@ while ($i < min($num, $limit))
print "<td>".dol_print_email($obj->email,0,0,1)."</td>\n"; print "<td>".dol_print_email($obj->email,0,0,1)."</td>\n";
} }
// End of subscription date // End of subscription date
$datefin=$db->jdate($obj->datefin); $datefin=$db->jdate($obj->datefin);
if (! empty($arrayfields['d.datefin']['checked'])) if (! empty($arrayfields['d.datefin']['checked']))
{ {
if ($datefin) if ($datefin)
@ -832,22 +844,15 @@ while ($i < min($num, $limit))
} }
// Action column // Action column
print '<td align="center">'; print '<td align="center">';
if ($user->rights->adherent->creer) if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{ {
print "<a href=\"card.php?rowid=".$obj->rowid."&action=edit&backtopage=1\">".img_edit()."</a>"; $selected=0;
} if (in_array($obj->rowid, $arrayofselected)) $selected=1;
print '&nbsp;'; print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
if ($user->rights->adherent->supprimer && $obj->statut == -1) }
{ print '</td>';
print "<a href=\"card.php?rowid=".$obj->rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png')."</a>"; if (! $i) $totalarray['nbfield']++;
}
if ($user->rights->adherent->supprimer && $obj->statut == 1)
{
print "<a href=\"card.php?rowid=".$obj->rowid."&action=resign&backtopage=1\">".img_picto($langs->trans("Resiliate"),'disable.png')."</a>";
}
print "</td>";
if (! $i) $totalarray['nbfield']++;
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }

View File

@ -45,7 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$langs->loadLangs(array("orders",'sendings','deliveries','companies','compta','bills')); $langs->loadLangs(array("orders",'sendings','deliveries','companies','compta','bills'));
$action=GETPOST('action','alpha'); $action=GETPOST('action','aZ09');
$massaction=GETPOST('massaction','alpha'); $massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int'); $show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
@ -160,7 +160,7 @@ if (empty($reshook))
{ {
// Selection of new fields // Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
{ {
@ -202,51 +202,51 @@ if (empty($reshook))
// TODO Move this into mass action include // TODO Move this into mass action include
if ($massaction == 'confirm_createbills') { if ($massaction == 'confirm_createbills') {
$orders = GETPOST('toselect'); $orders = GETPOST('toselect');
$createbills_onebythird = GETPOST('createbills_onebythird', 'int'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int');
$validate_invoices = GETPOST('valdate_invoices', 'int'); $validate_invoices = GETPOST('valdate_invoices', 'int');
$TFact = array(); $TFact = array();
$TFactThird = array(); $TFactThird = array();
$nb_bills_created = 0; $nb_bills_created = 0;
$db->begin(); $db->begin();
foreach($orders as $id_order) { foreach($orders as $id_order) {
$cmd = new Commande($db); $cmd = new Commande($db);
if($cmd->fetch($id_order) <= 0) continue; if($cmd->fetch($id_order) <= 0) continue;
$object = new Facture($db); $object = new Facture($db);
if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
else { else {
$object->socid = $cmd->socid; $object->socid = $cmd->socid;
$object->type = Facture::TYPE_STANDARD; $object->type = Facture::TYPE_STANDARD;
$object->cond_reglement_id = $cmd->cond_reglement_id; $object->cond_reglement_id = $cmd->cond_reglement_id;
$object->mode_reglement_id = $cmd->mode_reglement_id; $object->mode_reglement_id = $cmd->mode_reglement_id;
$object->fk_project = $cmd->fk_project; $object->fk_project = $cmd->fk_project;
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
if (empty($datefacture)) if (empty($datefacture))
{ {
$datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y")); $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y"));
} }
$object->date = $datefacture; $object->date = $datefacture;
$object->origin = 'commande'; $object->origin = 'commande';
$object->origin_id = $id_order; $object->origin_id = $id_order;
$res = $object->create($user); $res = $object->create($user);
if($res > 0) $nb_bills_created++; if($res > 0) $nb_bills_created++;
} }
if($object->id > 0) { if($object->id > 0) {
$db->begin(); $db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
$sql.= "fk_source"; $sql.= "fk_source";
@ -259,7 +259,7 @@ if (empty($reshook))
$sql.= ", ".$object->id; $sql.= ", ".$object->id;
$sql.= ", '".$object->element."'"; $sql.= ", '".$object->element."'";
$sql.= ")"; $sql.= ")";
if ($db->query($sql)) if ($db->query($sql))
{ {
$db->commit(); $db->commit();
@ -268,17 +268,17 @@ if (empty($reshook))
{ {
$db->rollback(); $db->rollback();
} }
$lines = $cmd->lines; $lines = $cmd->lines;
if (empty($lines) && method_exists($cmd, 'fetch_lines')) if (empty($lines) && method_exists($cmd, 'fetch_lines'))
{ {
$cmd->fetch_lines(); $cmd->fetch_lines();
$lines = $cmd->lines; $lines = $cmd->lines;
} }
$fk_parent_line=0; $fk_parent_line=0;
$num=count($lines); $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); $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
@ -367,43 +367,43 @@ if (empty($reshook))
$fk_parent_line = $result; $fk_parent_line = $result;
} }
} }
} }
} }
$cmd->classifyBilled($user); $cmd->classifyBilled($user);
if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object;
else $TFact[$object->id] = $object; else $TFact[$object->id] = $object;
} }
// Build doc with all invoices // Build doc with all invoices
$TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
$toselect = array(); $toselect = array();
if(!empty($validate_invoices)) { if(!empty($validate_invoices)) {
$massaction = $action = 'builddoc'; $massaction = $action = 'builddoc';
foreach($TAllFact as &$object) { foreach($TAllFact as &$object) {
$object->validate($user); $object->validate($user);
$toselect[] = $object->id; // For builddoc action $toselect[] = $object->id; // For builddoc action
// Fac builddoc // Fac builddoc
$upload_dir = $conf->facture->dir_output; $upload_dir = $conf->facture->dir_output;
$permissioncreate=$user->rights->facture->creer; $permissioncreate=$user->rights->facture->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
} }
$objectclass='Facture'; $objectclass='Facture';
$objectlabel='Invoice'; $objectlabel='Invoice';
$permtoread = $user->rights->facture->lire; $permtoread = $user->rights->facture->lire;
$permtodelete = $user->rights->facture->supprimer; $permtodelete = $user->rights->facture->supprimer;
$uploaddir = $conf->facture->dir_output; $uploaddir = $conf->facture->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
} }
if (! $error) if (! $error)
{ {
$db->commit(); $db->commit();
@ -418,7 +418,7 @@ if (empty($reshook))
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} }
} }
@ -596,9 +596,9 @@ if ($resql)
$title.=' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled)?'':$langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); $title.=' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled)?'':$langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill');
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$arrayofselected=is_array($toselect)?$toselect:array(); $arrayofselected=is_array($toselect)?$toselect:array();
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
@ -629,7 +629,7 @@ if ($resql)
$tmpkey=preg_replace('/search_options_/','',$key); $tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
} }
// List of mass actions available // List of mass actions available
$arrayofmassactions = array( $arrayofmassactions = array(
'presend'=>$langs->trans("SendByMail"), 'presend'=>$langs->trans("SendByMail"),
@ -653,12 +653,12 @@ if ($resql)
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">'; print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);
// TODO Move this into an invluce // TODO Move this into an invluce
if ($massaction == 'presend') if ($massaction == 'presend')
{ {
$langs->load("mails"); $langs->load("mails");
if (! GETPOST('cancel')) if (! GETPOST('cancel'))
{ {
$objecttmp=new Commande($db); $objecttmp=new Commande($db);
@ -677,14 +677,14 @@ if ($resql)
} }
} }
} }
print '<input type="hidden" name="massaction" value="confirm_presend">'; print '<input type="hidden" name="massaction" value="confirm_presend">';
dol_fiche_head(null, '', ''); dol_fiche_head(null, '', '');
$topicmail="SendOrderRef"; $topicmail="SendOrderRef";
$modelmail="order_send"; $modelmail="order_send";
// Cree l'objet formulaire mail // Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db); $formmail = new FormMail($db);
@ -737,23 +737,23 @@ if ($resql)
$formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag
$formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__PERSONALIZED__']='';
$formmail->substit['__CONTACTCIVNAME__']=''; $formmail->substit['__CONTACTCIVNAME__']='';
// Tableau des parametres complementaires du post // Tableau des parametres complementaires du post
$formmail->param['action']=$action; $formmail->param['action']=$action;
$formmail->param['models']=$modelmail; $formmail->param['models']=$modelmail;
$formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['id']=join(',',$arrayofselected); $formmail->param['id']=join(',',$arrayofselected);
//$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
print $formmail->get_form(); print $formmail->get_form();
dol_fiche_end(); dol_fiche_end();
} }
elseif ($massaction == 'createbills') elseif ($massaction == 'createbills')
{ {
//var_dump($_REQUEST); //var_dump($_REQUEST);
print '<input type="hidden" name="massaction" value="confirm_createbills">'; print '<input type="hidden" name="massaction" value="confirm_createbills">';
print '<table class="border" width="100%" >'; print '<table class="border" width="100%" >';
print '<tr>'; print '<tr>';
print '<td class="titlefieldmiddle">'; print '<td class="titlefieldmiddle">';
@ -780,7 +780,7 @@ if ($resql)
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
print '<br>'; print '<br>';
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisCustomer').'"> '; print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisCustomer').'"> ';
@ -788,13 +788,13 @@ if ($resql)
print '</div>'; print '</div>';
print '<br>'; print '<br>';
} }
if ($sall) if ($sall)
{ {
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
} }
$moreforfilter=''; $moreforfilter='';
// If the user can view prospects other than his' // If the user can view prospects other than his'
@ -828,7 +828,7 @@ if ($resql)
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint;
if (! empty($moreforfilter)) if (! empty($moreforfilter))
{ {
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
@ -839,27 +839,27 @@ if ($resql)
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
// Ref // Ref
if (! empty($arrayfields['c.ref']['checked'])) if (! empty($arrayfields['c.ref']['checked']))
{ {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<input class="flat" size="6" type="text" name="search_ref" value="'.$search_ref.'">'; print '<input class="flat" size="6" type="text" name="search_ref" value="'.$search_ref.'">';
print '</td>'; print '</td>';
} }
// Ref customer // Ref customer
if (! empty($arrayfields['c.ref_client']['checked'])) if (! empty($arrayfields['c.ref_client']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" size="6" name="search_ref_customer" value="'.$search_ref_customer.'">'; print '<input class="flat" type="text" size="6" name="search_ref_customer" value="'.$search_ref_customer.'">';
print '</td>'; print '</td>';
} }
// Thirpdarty // Thirpdarty
if (! empty($arrayfields['s.nom']['checked'])) if (! empty($arrayfields['s.nom']['checked']))
{ {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" name="search_company" value="'.$search_company.'">'; print '<input class="flat" type="text" name="search_company" value="'.$search_company.'">';
@ -899,7 +899,7 @@ if ($resql)
$formother->select_year($orderyear?$orderyear:-1,'orderyear',1, 20, 5); $formother->select_year($orderyear?$orderyear:-1,'orderyear',1, 20, 5);
print '</td>'; print '</td>';
} }
if (! empty($arrayfields['c.date_delivery']['checked'])) if (! empty($arrayfields['c.date_delivery']['checked']))
{ {
print '<td class="liste_titre" align="center">'; print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="deliveryday" value="'.$deliveryday.'">'; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="deliveryday" value="'.$deliveryday.'">';
@ -972,10 +972,10 @@ if ($resql)
{ {
print '<td class="liste_titre maxwidthonsmartphone" align="right">'; print '<td class="liste_titre maxwidthonsmartphone" align="right">';
$liststatus=array( $liststatus=array(
Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"),
Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"),
Commande::STATUS_ACCEPTED=>$langs->trans("StatusOrderSentShort"), Commande::STATUS_ACCEPTED=>$langs->trans("StatusOrderSentShort"),
Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"),
Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort")
); );
print $form->selectarray('viewstatut', $liststatus, $viewstatut, -4); print $form->selectarray('viewstatut', $liststatus, $viewstatut, -4);
@ -993,7 +993,7 @@ if ($resql)
$searchpicto=$form->showFilterButtons(); $searchpicto=$form->showFilterButtons();
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
// Fields title // Fields title
@ -1014,9 +1014,9 @@ if ($resql)
// Extra fields // Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{ {
foreach($extrafields->attribute_label as $key => $val) foreach($extrafields->attribute_label as $key => $val)
{ {
if (! empty($arrayfields["ef.".$key]['checked'])) if (! empty($arrayfields["ef.".$key]['checked']))
{ {
$align=$extrafields->getAlignFlag($key); $align=$extrafields->getAlignFlag($key);
print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
@ -1033,20 +1033,20 @@ if ($resql)
if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'],$_SERVER["PHP_SELF"],'c.facture','',$param,'align="center"',$sortfield,$sortorder,''); if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'],$_SERVER["PHP_SELF"],'c.facture','',$param,'align="center"',$sortfield,$sortorder,'');
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
print '</tr>'."\n"; print '</tr>'."\n";
$total=0; $total=0;
$subtotal=0; $subtotal=0;
$productstat_cache=array(); $productstat_cache=array();
$generic_commande = new Commande($db); $generic_commande = new Commande($db);
$generic_product = new Product($db); $generic_product = new Product($db);
$i=0; $i=0;
$totalarray=array(); $totalarray=array();
while ($i < min($num,$limit)) while ($i < min($num,$limit))
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
$notshippable=0; $notshippable=0;
@ -1054,7 +1054,7 @@ if ($resql)
$text_info=''; $text_info='';
$text_warning=''; $text_warning='';
$nbprod=0; $nbprod=0;
// Ref // Ref
if (! empty($arrayfields['c.ref']['checked'])) if (! empty($arrayfields['c.ref']['checked']))
{ {
@ -1070,12 +1070,12 @@ if ($resql)
$generic_commande->total_ttc = $obj->total_ttc; $generic_commande->total_ttc = $obj->total_ttc;
$generic_commande->lines=array(); $generic_commande->lines=array();
$generic_commande->getLinesArray(); $generic_commande->getLinesArray();
print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding nowrap">'; print '<td class="nobordernopadding nowrap">';
print $generic_commande->getNomUrl(1,($viewstatut != 2?0:$obj->fk_statut)); print $generic_commande->getNomUrl(1,($viewstatut != 2?0:$obj->fk_statut));
print '</td>'; print '</td>';
// Show shippable Icon (create subloop, so may be slow) // Show shippable Icon (create subloop, so may be slow)
if ($conf->stock->enabled) if ($conf->stock->enabled)
{ {
@ -1083,7 +1083,7 @@ if ($resql)
if (($obj->fk_statut > 0) && ($obj->fk_statut < 3)) if (($obj->fk_statut > 0) && ($obj->fk_statut < 3))
{ {
$numlines = count($generic_commande->lines); // Loop on each line of order $numlines = count($generic_commande->lines); // Loop on each line of order
for ($lig=0; $lig < $numlines; $lig++) for ($lig=0; $lig < $numlines; $lig++)
{ {
if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) // If line is a product and not a service if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) // If line is a product and not a service
{ {
@ -1107,8 +1107,8 @@ if ($resql)
$text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel; $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel;
$text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique; $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique;
$text_info .= '<br>'; $text_info .= '<br>';
if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel)
{ {
$notshippable++; $notshippable++;
} }
@ -1168,7 +1168,7 @@ if ($resql)
$text_info = $langs->trans('NonShippable').'<br>'.$text_info; $text_info = $langs->trans('NonShippable').'<br>'.$text_info;
} }
} }
print '<td>'; print '<td>';
if ($nbprod) if ($nbprod)
{ {
@ -1179,7 +1179,7 @@ if ($resql)
} }
print '</td>'; print '</td>';
} }
// Warning late icon and note // Warning late icon and note
print '<td class="nobordernopadding nowrap">'; print '<td class="nobordernopadding nowrap">';
if ($generic_commande->hasDelay()) { if ($generic_commande->hasDelay()) {
@ -1192,7 +1192,7 @@ if ($resql)
print '</span>'; print '</span>';
} }
print '</td>'; print '</td>';
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">'; print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
$filename=dol_sanitizeFileName($obj->ref); $filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
@ -1200,11 +1200,11 @@ if ($resql)
print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
print '</td>'; print '</td>';
print '</tr></table>'; print '</tr></table>';
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Ref customer // Ref customer
if (! empty($arrayfields['c.ref_client']['checked'])) if (! empty($arrayfields['c.ref_client']['checked']))
{ {
@ -1222,7 +1222,7 @@ if ($resql)
{ {
print '<td class="tdoverflowmax200">'; print '<td class="tdoverflowmax200">';
print $companystatic->getNomUrl(1,'customer'); print $companystatic->getNomUrl(1,'customer');
// If module invoices enabled and user with invoice creation permissions // If module invoices enabled and user with invoice creation permissions
if (! empty($conf->facture->enabled) && ! empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) if (! empty($conf->facture->enabled) && ! empty($conf->global->ORDER_BILLING_ALL_CUSTOMER))
{ {
@ -1278,7 +1278,7 @@ if ($resql)
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Order date // Order date
if (! empty($arrayfields['c.date_commande']['checked'])) if (! empty($arrayfields['c.date_commande']['checked']))
{ {
@ -1319,7 +1319,7 @@ if ($resql)
if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
$totalarray['totalttc'] += $obj->total_ttc; $totalarray['totalttc'] += $obj->total_ttc;
} }
// Extra fields // Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{ {
@ -1370,7 +1370,7 @@ if ($resql)
print '<td align="center">'.yn($obj->billed).'</td>'; print '<td align="center">'.yn($obj->billed).'</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Action column // Action column
print '<td class="nowrap" align="center">'; print '<td class="nowrap" align="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
@ -1381,9 +1381,9 @@ if ($resql)
} }
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
print "</tr>\n"; print "</tr>\n";
$total+=$obj->total_ht; $total+=$obj->total_ht;
$subtotal+=$obj->total_ht; $subtotal+=$obj->total_ht;
$i++; $i++;
@ -1416,14 +1416,14 @@ if ($resql)
} }
$db->free($resql); $db->free($resql);
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
print '</table>'."\n"; print '</table>'."\n";
print '</div>'; print '</div>';
print '</form>'."\n"; print '</form>'."\n";
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
@ -1433,18 +1433,18 @@ if ($resql)
*/ */
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&amp;','&',$param); $urlsource.=str_replace('&amp;','&',$param);
$filedir=$diroutputmassaction; $filedir=$diroutputmassaction;
$genallowed=$user->rights->commande->lire; $genallowed=$user->rights->commande->lire;
$delallowed=$user->rights->commande->supprimer; $delallowed=$user->rights->commande->supprimer;
print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
} }
else else
{ {
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>'; print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
} }
} }
else else
{ {

View File

@ -536,7 +536,7 @@ if (! $error && $massaction == 'delete' && $permtodelete)
$result=$objecttmp->fetch($toselectid); $result=$objecttmp->fetch($toselectid);
if ($result > 0) if ($result > 0)
{ {
if ($objecttmp->element == 'societe') $result = $objecttmp->delete($objecttmp->id, $user, 1); if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1);
else $result = $objecttmp->delete($user); else $result = $objecttmp->delete($user);
if ($result <= 0) if ($result <= 0)
{ {