Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2016-07-20 19:01:55 +02:00
commit a37caae098
30 changed files with 1665 additions and 799 deletions

View File

@ -1096,21 +1096,36 @@ class ActionComm extends CommonObject
*/
function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='',$overwritepicto=0)
{
global $conf,$langs;
global $conf,$langs, $hookmanager;
$result='';
$tooltip = '<u>' . $langs->trans('ShowAction'.$objp->code) . '</u>';
if (! empty($this->ref))
$tooltip .= '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
if (! empty($this->label))
$tooltip .= '<br><b>' . $langs->trans('Title') . ':</b> ' . $this->label;
$label = $this->label;
if (empty($label)) $label=$this->libelle; // For backward compatibility
$linkclose = '" title="'.dol_escape_htmltag($tooltip, 1).'">';
if ($option=='birthday') $link = '<a class="'.$classname.' classfortooltip" href="'.DOL_URL_ROOT.'/contact/perso.php?id='.$this->id.$linkclose;
else $link = '<a class="'.$classname.' classfortooltip" href="'.DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id.$linkclose;
$linkend='</a>';
//print 'rrr'.$this->libelle.'-'.$withpicto;
$result='';
$tooltip = '<u>' . $langs->trans('ShowAction'.$objp->code) . '</u>';
if (! empty($this->ref))
$tooltip .= '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$label = $this->label;
if (empty($label)) $label=$this->libelle; // For backward compatibility
if (! empty($label))
$tooltip .= '<br><b>' . $langs->trans('Title') . ':</b> ' . $label;
if (! empty($this->location))
$tooltip .= '<br><b>' . $langs->trans('Location') . ':</b> ' . $this->location;
$linkclose = ' class="'.$classname.' classfortooltip" title="'.dol_escape_htmltag($tooltip, 1).'">';
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('actiondao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
$linkclose = ($hookmanager->resPrint ? $hookmanager->resPrint : $linkclose);
if ($option=='birthday')
$link = '<a href="'.DOL_URL_ROOT.'/contact/perso.php?id='.$this->id.'"'.$linkclose;
else
$link = '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id.'"'.$linkclose;
$linkend='</a>';
//print 'rrr'.$this->libelle.'-'.$withpicto;
if ($withpicto == 2)
{

View File

@ -3,6 +3,7 @@
* Copyright (C) 2008-2009 Laurent Destailleur (Eldy) <eldy@users.sourceforge.net>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com
* Copyright (C) 2016 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -166,10 +167,12 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
// Social contributions
$sql3= " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr";
$sql3.= ", cs.fk_account";
$sql3.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs";
$sql3.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id";
$sql3.= " WHERE cs.entity = ".$conf->entity;
$sql3.= " AND cs.paye = 0"; // Not paid
$sql3.= " AND (cs.fk_account IN (0, ".$acct->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution
$sql3.= " ORDER BY dlr ASC";
$error=0;

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -159,6 +160,8 @@ if ($_GET["action"] == 'create')
$charge = new ChargeSociales($db);
$charge->fetch($chid);
$charge->accountid=$charge->fk_account?$charge->fk_account:$charge->accountid;
$charge->paiementtype=$charge->mode_reglement_id?$charge->mode_reglement_id:$charge->paiementtype;
$total = $charge->amount;
@ -178,16 +181,16 @@ if ($_GET["action"] == 'create')
dol_fiche_head('', '');
print '<table cellspacing="0" class="border" width="100%" cellpadding="2">';
print '<table class="border" width="100%">';
print "<tr class=\"liste_titre\"><td colspan=\"3\">".$langs->trans("SocialContribution")."</td>";
print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("SocialContribution")."</td></tr>";
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid.'">'.$chid.'</a></td></tr>';
print '<tr><td>'.$langs->trans("Type")."</td><td colspan=\"2\">".$charge->type_libelle."</td></tr>\n";
print '<tr><td>'.$langs->trans("Period")."</td><td colspan=\"2\">".dol_print_date($charge->periode,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$charge->lib."</td></tr>\n";
print '<tr><td>'.$langs->trans("DateDue")."</td><td colspan=\"2\">".dol_print_date($charge->date_ech,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Amount")."</td><td colspan=\"2\">".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans("Ref").'</td><td><a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid.'">'.$chid.'</a></td></tr>';
print '<tr><td>'.$langs->trans("Type")."</td><td>".$charge->type_libelle."</td></tr>\n";
print '<tr><td>'.$langs->trans("Period")."</td><td>".dol_print_date($charge->periode,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$charge->lib."</td></tr>\n";
print '<tr><td>'.$langs->trans("DateDue")."</td><td>".dol_print_date($charge->date_ech,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Amount")."</td><td>".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
$sql = "SELECT sum(p.amount) as total";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
@ -199,28 +202,28 @@ if ($_GET["action"] == 'create')
$sumpaid = $obj->total;
$db->free();
}
print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td colspan="2">'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td valign="top">'.$langs->trans("RemainderToPay").'</td><td colspan="2">'.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td>'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td valign="top">'.$langs->trans("RemainderToPay").'</td><td>'.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr class="liste_titre">';
print "<td colspan=\"3\">".$langs->trans("Payment").'</td>';
print "<td colspan=\"2\">".$langs->trans("Payment").'</td>';
print '</tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td colspan="2">';
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
$datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0;
$form->select_date($datepayment,'','','','',"add_payment",1,1);
print "</td>";
print '</tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td colspan="2">';
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
$form->select_types_paiements(isset($_POST["paiementtype"])?$_POST["paiementtype"]:$charge->paiementtype, "paiementtype");
print "</td>\n";
print '</tr>';
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
print '<td colspan="2">';
print '<td>';
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '',1); // Show opend bank account list
print '</td></tr>';
@ -228,11 +231,11 @@ if ($_GET["action"] == 'create')
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</td>';
print '<td colspan="2"><input name="num_paiement" type="text" value="'.GETPOST('num_paiement').'"></td></tr>'."\n";
print '<td><input name="num_paiement" type="text" value="'.GETPOST('num_paiement').'"></td></tr>'."\n";
print '<tr>';
print '<td valign="top">'.$langs->trans("Comments").'</td>';
print '<td valign="top" colspan="2"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
print '<td valign="top"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
print '</tr>';
print '</table>';

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -71,6 +72,23 @@ if ($action == 'reopen' && $user->rights->tax->charges->creer) {
}
}
// payment mode
if ($action == 'setmode' && $user->rights->tax->charges->creer) {
$object->fetch($id);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
}
// bank account
if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
$object->fetch($id);
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
// Delete social contribution
if ($action == 'confirm_delete' && $confirm == 'yes')
{
@ -127,6 +145,8 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
$object->date_ech=$dateech;
$object->periode=$dateperiod;
$object->amount=$amount;
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$id=$object->create($user);
if ($id <= 0)
@ -290,6 +310,17 @@ if ($action == 'create')
print '</td>';
print '<td><input type="text" size="6" name="amount" class="flat" value="'.GETPOST('amount').'"></td>';
print '</tr>';
// Payment Mode
print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
print '</td></tr>';
// Bank Account
if (! empty($conf->banque->enabled))
{
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>';
}
// Date due
print '<tr>';
print '<td class="fieldrequired">';
@ -313,7 +344,7 @@ if ($action == 'create')
/* *************************************************************************** */
/* */
/* Mode fiche */
/* Card Mode */
/* */
/* *************************************************************************** */
if ($id > 0)
@ -382,7 +413,8 @@ if ($id > 0)
// Type
print "<tr><td>".$langs->trans("Type")."</td><td>".$object->type_libelle."</td>";
$rowspan=5;
$rowspan=6;
if (! empty($conf->banque->enabled)) $rowspan++;
print '<td rowspan="'.$rowspan.'" valign="top">';
/*
@ -422,8 +454,8 @@ if ($id > 0)
print "<tr ".$bc[$var]."><td>";
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
$labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
$labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
print '<td align="right">'.price($objp->amount)."</td><td>&nbsp;".$langs->trans("Currency".$conf->currency)."</td>\n";
print "</tr>";
$totalpaye += $objp->amount;
@ -432,12 +464,12 @@ if ($id > 0)
if ($object->paye == 0)
{
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\"><b>".price($totalpaye)."</b></td><td>&nbsp;".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($object->amount)."</td><td bgcolor=\"#d0d0d0\">&nbsp;".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\"><b>".price($totalpaye)."</b></td><td>&nbsp;".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($object->amount)."</td><td bgcolor=\"#d0d0d0\">&nbsp;".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
$resteapayer = $object->amount - $totalpaye;
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($resteapayer)."</b></td><td bgcolor=\"#f0f0f0\">&nbsp;".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
}
print "</table>";
@ -486,6 +518,42 @@ if ($id > 0)
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
}
// Mode of payment
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($action != 'editmode')
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editmode') {
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
} else {
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none');
}
print '</td></tr>';
// Bank Account
if (! empty($conf->banque->enabled))
{
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('BankAccount');
print '<td>';
if ($action != 'editbankaccount' && $user->rights->tax->charges->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
}
print '</td>';
print '</tr>';
}
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>';
@ -500,7 +568,7 @@ if ($id > 0)
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div';
print '</div>';
}
if ($action == 'edit') print "</form>\n";

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -49,6 +50,7 @@ class ChargeSociales extends CommonObject
var $date_creation;
var $date_modification;
var $date_validation;
var $fk_account;
/**
@ -71,13 +73,16 @@ class ChargeSociales extends CommonObject
*/
function fetch($id, $ref='')
{
$sql = "SELECT cs.rowid, cs.date_ech,";
$sql.= " cs.libelle as lib, cs.fk_type, cs.amount, cs.paye, cs.periode, cs.import_key,";
$sql.= " c.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs, ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= " WHERE cs.fk_type = c.id";
if ($ref) $sql.= " AND cs.rowid = ".$ref;
else $sql.= " AND cs.rowid = ".$id;
$sql = "SELECT cs.rowid, cs.date_ech";
$sql.= ", cs.libelle as lib, cs.fk_type, cs.amount, cs.paye, cs.periode, cs.import_key";
$sql.= ", cs.fk_account, cs.fk_mode_reglement";
$sql.= ", c.libelle";
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id';
if ($ref) $sql.= " WHERE cs.rowid = ".$ref;
else $sql.= " WHERE cs.rowid = ".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
@ -93,6 +98,10 @@ class ChargeSociales extends CommonObject
$this->lib = $obj->lib;
$this->type = $obj->fk_type;
$this->type_libelle = $obj->libelle;
$this->fk_account = $obj->fk_account;
$this->mode_reglement_id = $obj->fk_mode_reglement;
$this->mode_reglement_code = $obj->mode_reglement_code;
$this->mode_reglement = $obj->mode_reglement_libelle;
$this->amount = $obj->amount;
$this->paye = $obj->paye;
$this->periode = $this->db->jdate($obj->periode);
@ -155,8 +164,11 @@ class ChargeSociales extends CommonObject
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, libelle, date_ech, periode, amount, entity)";
$sql.= " VALUES (".$this->type.",'".$this->db->escape($this->lib)."',";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, entity)";
$sql.= " VALUES (".$this->type;
$sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
$sql.= ", ".($this->mode_reglement_id>0?"'".$this->mode_reglement_id."'":"NULL");
$sql.= ", '".$this->db->escape($this->lib)."',";
$sql.= " '".$this->db->idate($this->date_ech)."','".$this->db->idate($this->periode)."',";
$sql.= " '".price2num($newamount)."',";
$sql.= " ".$conf->entity;
@ -216,7 +228,7 @@ class ChargeSociales extends CommonObject
// Delete payments
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge where fk_charge='".$this->id."'";
$sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge='".$this->id."'";
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
@ -228,7 +240,7 @@ class ChargeSociales extends CommonObject
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales where rowid='".$this->id."'";
$sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid='".$this->id."'";
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -255,7 +256,7 @@ if ($resql)
// Due date
print '<td width="110" align="center">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
print '<td align="right" class="nowrap">'.$chargesociale_static->LibStatut($obj->paye,5,$obj->alreadypayed).'</a></td>';
print '<td align="right" class="nowrap">'.$chargesociale_static->LibStatut($obj->paye,5,$obj->alreadypayed).'</td>';
print '<td></td>';

View File

@ -957,39 +957,53 @@ class Contact extends CommonObject
*/
function getNomUrl($withpicto=0,$option='',$maxlen=0,$moreparam='')
{
global $conf, $langs;
global $conf, $langs, $hookmanager;
$result='';
$label = '<u>' . $langs->trans("ShowContact") . '</u>';
$label.= '<br><b>' . $langs->trans("Name") . ':</b> '.$this->getFullName($langs);
//if ($this->civility_id) $label.= '<br><b>' . $langs->trans("Civility") . ':</b> '.$this->civility_id; // TODO Translate cibilty_id code
if (! empty($this->poste)) $label.= '<br><b>' . $langs->trans("Poste") . ':</b> '.$this->poste;
$label.= '<br><b>' . $langs->trans("EMail") . ':</b> '.$this->email;
$phonelist=array();
if ($this->phone_pro) $phonelist[]=$this->phone_pro;
if ($this->phone_mobile) $phonelist[]=$this->phone_mobile;
if ($this->phone_perso) $phonelist[]=$this->phone_perso;
$label.= '<br><b>' . $langs->trans("Phone") . ':</b> '.join(', ',$phonelist);
$label.= '<br><b>' . $langs->trans("Address") . ':</b> '.dol_format_address($this, 1, ' ', $langs);
$label = '<u>' . $langs->trans("ShowContact") . '</u>';
$label.= '<br><b>' . $langs->trans("Name") . ':</b> '.$this->getFullName($langs);
//if ($this->civility_id) $label.= '<br><b>' . $langs->trans("Civility") . ':</b> '.$this->civility_id; // TODO Translate cibilty_id code
if (! empty($this->poste)) $label.= '<br><b>' . $langs->trans("Poste") . ':</b> '.$this->poste;
$label.= '<br><b>' . $langs->trans("EMail") . ':</b> '.$this->email;
$phonelist=array();
if ($this->phone_pro) $phonelist[]=$this->phone_pro;
if ($this->phone_mobile) $phonelist[]=$this->phone_mobile;
if ($this->phone_perso) $phonelist[]=$this->phone_perso;
$label.= '<br><b>' . $langs->trans("Phone") . ':</b> '.join(', ',$phonelist);
$label.= '<br><b>' . $langs->trans("Address") . ':</b> '.dol_format_address($this, 1, ' ', $langs);
$link = '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$this->id.$moreparam.'"';
$linkclose="";
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowContact");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.= ' class="classfortooltip">';
$link = '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$this->id.$moreparam.'"';
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowContact");
$link.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$link.= ' title="'.dol_escape_htmltag($label, 1).'"';
$link.= ' class="classfortooltip">';
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('contactdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
$link.=$linkclose;
$linkend='</a>';
if ($option == 'xxx')
{
$link = '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$this->id.$moreparam.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
}
if ($withpicto) $result.=($link.img_object($label, 'contact', 'class="classfortooltip"').$linkend.' ');
$result.=$link.($maxlen?dol_trunc($this->getFullName($langs),$maxlen):$this->getFullName($langs)).$linkend;
if ($withpicto) $result.=($link.img_object($label, 'contact', 'class="classfortooltip"').$linkend.' ');
$result.=$link.($maxlen?dol_trunc($this->getFullName($langs),$maxlen):$this->getFullName($langs)).$linkend;
return $result;
}

View File

@ -619,54 +619,52 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
// If syslog module enabled
if (empty($conf->syslog->enabled)) return;
if (! empty($level))
// Test log level
$logLevels = array(LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG);
if (!in_array($level, $logLevels, true))
{
// Test log level
$logLevels = array( LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG);
if (!in_array($level, $logLevels))
{
throw new Exception('Incorrect log level');
}
if ($level > $conf->global->SYSLOG_LEVEL) return;
// If adding log inside HTML page is required
if (! empty($_REQUEST['logtohtml']) && (! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || ! empty($conf->global->MAIN_LOGTOHTML))) // MAIN_LOGTOHTML kept for backward compatibility
{
$conf->logbuffer[] = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message;
}
//TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output
// If enable html log tag enabled and url parameter log defined, we show output log on HTML comments
if (! empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && ! empty($_GET["log"]))
{
print "\n\n<!-- Log start\n";
print $message."\n";
print "Log end -->\n";
}
$data = array(
'message' => $message,
'script' => (isset($_SERVER['PHP_SELF'])? basename($_SERVER['PHP_SELF'],'.php') : false),
'level' => $level,
'user' => ((is_object($user) && $user->id) ? $user->login : false),
'ip' => false
);
if (! empty($_SERVER["REMOTE_ADDR"])) $data['ip'] = $_SERVER['REMOTE_ADDR'];
// This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache)
else if (! empty($_SERVER['SERVER_ADDR'])) $data['ip'] = $_SERVER['SERVER_ADDR'];
// This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it).
else if (! empty($_SERVER['COMPUTERNAME'])) $data['ip'] = $_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME'])?'':'@'.$_SERVER['USERNAME']);
// This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it).
else if (! empty($_SERVER['LOGNAME'])) $data['ip'] = '???@'.$_SERVER['LOGNAME'];
// Loop on each log handler and send output
foreach ($conf->loghandlers as $loghandlerinstance)
{
if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) continue;
$loghandlerinstance->export($data,$suffixinfilename);
}
unset($data);
throw new Exception('Incorrect log level');
}
if ($level > $conf->global->SYSLOG_LEVEL) return;
// If adding log inside HTML page is required
if (! empty($_REQUEST['logtohtml']) && (! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || ! empty($conf->global->MAIN_LOGTOHTML))) // MAIN_LOGTOHTML kept for backward compatibility
{
$conf->logbuffer[] = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message;
}
//TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output
// If enable html log tag enabled and url parameter log defined, we show output log on HTML comments
if (! empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && ! empty($_GET["log"]))
{
print "\n\n<!-- Log start\n";
print $message."\n";
print "Log end -->\n";
}
$data = array(
'message' => $message,
'script' => (isset($_SERVER['PHP_SELF'])? basename($_SERVER['PHP_SELF'],'.php') : false),
'level' => $level,
'user' => ((is_object($user) && $user->id) ? $user->login : false),
'ip' => false
);
if (! empty($_SERVER["REMOTE_ADDR"])) $data['ip'] = $_SERVER['REMOTE_ADDR'];
// This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache)
else if (! empty($_SERVER['SERVER_ADDR'])) $data['ip'] = $_SERVER['SERVER_ADDR'];
// This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it).
else if (! empty($_SERVER['COMPUTERNAME'])) $data['ip'] = $_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME'])?'':'@'.$_SERVER['USERNAME']);
// This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it).
else if (! empty($_SERVER['LOGNAME'])) $data['ip'] = '???@'.$_SERVER['LOGNAME'];
// Loop on each log handler and send output
foreach ($conf->loghandlers as $loghandlerinstance)
{
if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) continue;
$loghandlerinstance->export($data,$suffixinfilename);
}
unset($data);
if (! empty($ident))
{

View File

@ -72,6 +72,18 @@ class pdf_rouget extends ModelePdfExpedition
$this->posxweightvol=$this->page_largeur - $this->marge_droite - 76;
$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56;
$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28;
$this->posxpuht=$this->page_largeur - $this->marge_droite;
if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
$this->posxweightvol=$this->page_largeur - $this->marge_droite - 130;
$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 100;
$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 70;
$this->posxpuht=$this->page_largeur - $this->marge_droite - 40;
$this->posxtotalht=$this->page_largeur - $this->marge_droite - 20;
}
$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
@ -464,7 +476,17 @@ class pdf_rouget extends ModelePdfExpedition
}
$pdf->SetXY($this->posxqtytoship, $curY);
$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C');
$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C');
if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT))
{
$pdf->SetXY($this->posxpuht, $curY);
$pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R');
$pdf->SetXY($this->posxtotalht, $curY);
$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R');
}
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@ -628,7 +650,17 @@ class pdf_rouget extends ModelePdfExpedition
}
$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->largeur_page - $this->marge_droite - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
}
// Total Weight
if ($totalWeighttoshow)
@ -713,8 +745,27 @@ class pdf_rouget extends ModelePdfExpedition
if (empty($hidetop))
{
$pdf->SetXY($this->posxqtytoship, $tab_top+1);
$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C');
$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C');
}
if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
$pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxpuht-1, $tab_top+1);
$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C');
}
$pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxtotalht-1, $tab_top+1);
$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C');
}
}
}
/**

View File

@ -50,89 +50,89 @@ class CommandeFournisseur extends CommonOrder
*/
protected $table_ref_field = 'ref';
var $id;
public $id;
/**
* Supplier order reference
* @var string
*/
var $ref;
var $ref_supplier;
var $brouillon;
var $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially
public $ref;
public $ref_supplier;
public $brouillon;
public $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially
// -> 7=Canceled/Never received -> (reopen) 3=Process runing
// -> 6=Canceled -> (reopen) 2=Approved
// -> 9=Refused -> (reopen) 1=Validated
// Note: billed or not is on another field "billed"
var $statuts; // List of status
var $socid;
var $fourn_id;
var $date;
var $date_valid;
var $date_approve;
var $date_approve2; // Used when SUPPLIER_ORDER_DOUBLE_APPROVAL is set
var $date_commande;
public $statuts; // List of status
public $socid;
public $fourn_id;
public $date;
public $date_valid;
public $date_approve;
public $date_approve2; // Used when SUPPLIER_ORDER_DOUBLE_APPROVAL is set
public $date_commande;
/**
* Delivery date
*/
var $date_livraison;
var $total_ht;
var $total_tva;
var $total_localtax1; // Total Local tax 1
var $total_localtax2; // Total Local tax 2
var $total_ttc;
var $source;
public $date_livraison;
public $total_ht;
public $total_tva;
public $total_localtax1; // Total Local tax 1
public $total_localtax2; // Total Local tax 2
public $total_ttc;
public $source;
/**
* @deprecated
* @see note_private, note_public
*/
var $note;
public $note;
public $note_private;
public $note_public;
var $model_pdf;
var $fk_project;
var $cond_reglement_id;
var $cond_reglement_code;
var $fk_account;
var $mode_reglement_id;
var $mode_reglement_code;
var $user_author_id;
var $user_valid_id;
var $user_approve_id;
var $user_approve_id2; // Used when SUPPLIER_ORDER_DOUBLE_APPROVAL is set
public $model_pdf;
public $fk_project;
public $cond_reglement_id;
public $cond_reglement_code;
public $fk_account;
public $mode_reglement_id;
public $mode_reglement_code;
public $user_author_id;
public $user_valid_id;
public $user_approve_id;
public $user_approve_id2; // Used when SUPPLIER_ORDER_DOUBLE_APPROVAL is set
//Incoterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
public $fk_incoterms;
public $location_incoterms;
public $libelle_incoterms; //Used into tooltip
var $extraparams=array();
public $extraparams=array();
/**
* @var CommandeFournisseurLigne[]
*/
public $lines = array();
//Add for supplier_proposal
var $origin;
var $origin_id;
var $linked_objects=array();
public $origin;
public $origin_id;
public $linked_objects=array();
// Multicurrency
var $fk_multicurrency;
var $multicurrency_code;
var $multicurrency_tx;
var $multicurrency_total_ht;
var $multicurrency_total_tva;
var $multicurrency_total_ttc;
public $fk_multicurrency;
public $multicurrency_code;
public $multicurrency_tx;
public $multicurrency_total_ht;
public $multicurrency_total_tva;
public $multicurrency_total_ttc;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
public function __construct($db)
{
global $conf;
@ -161,7 +161,7 @@ class CommandeFournisseur extends CommonOrder
* @param string $ref Ref of object
* @return int >0 if OK, <0 if KO, 0 if not found
*/
function fetch($id,$ref='')
public function fetch($id,$ref='')
{
global $conf;
@ -373,7 +373,7 @@ class CommandeFournisseur extends CommonOrder
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK
*/
function valid($user,$idwarehouse=0,$notrigger=0)
public function valid($user,$idwarehouse=0,$notrigger=0)
{
global $langs,$conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -492,7 +492,7 @@ class CommandeFournisseur extends CommonOrder
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto
* @return string Label
*/
function getLibStatut($mode=0)
public function getLibStatut($mode=0)
{
return $this->LibStatut($this->statut,$mode,$this->billed);
}
@ -584,7 +584,7 @@ class CommandeFournisseur extends CommonOrder
* @param string $option On what the link points
* @return string Chain with URL
*/
function getNomUrl($withpicto=0,$option='')
public function getNomUrl($withpicto=0,$option='')
{
global $langs, $conf;
@ -620,7 +620,7 @@ class CommandeFournisseur extends CommonOrder
* @param Societe $soc company object
* @return string free reference for the invoice
*/
function getNextNumRef($soc)
public function getNextNumRef($soc)
{
global $db, $langs, $conf;
$langs->load("orders");
@ -674,8 +674,9 @@ class CommandeFournisseur extends CommonOrder
* @param User $user Object user making the change
* @return int <0 if KO, >0 if KO
*/
function classifyBilled(User $user)
public function classifyBilled(User $user)
{
$error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur SET billed = 1';
@ -720,7 +721,7 @@ class CommandeFournisseur extends CommonOrder
* @param int $secondlevel 0=Standard approval, 1=Second level approval (used when option SUPPLIER_ORDER_DOUBLE_APPROVAL is set)
* @return int <0 if KO, >0 if OK
*/
function approve($user, $idwarehouse=0, $secondlevel=0)
public function approve($user, $idwarehouse=0, $secondlevel=0)
{
global $langs,$conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -805,6 +806,7 @@ class CommandeFournisseur extends CommonOrder
// Product with reference
if ($this->lines[$i]->fk_product > 0)
{
$this->line = $this->lines[$i];
$mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
// We decrement stock of product (and sub-products)
@ -812,6 +814,7 @@ class CommandeFournisseur extends CommonOrder
if (! empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc=price2num($up_ht_disc * (100 - $this->lines[$i]->remise_percent) / 100, 'MU');
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("OrderApprovedInDolibarr",$this->ref));
if ($result < 0) { $error++; }
unset($this->line);
}
}
}
@ -870,7 +873,7 @@ class CommandeFournisseur extends CommonOrder
* @param User $user User making action
* @return int 0 if Ok, <0 if Ko
*/
function refuse($user)
public function refuse($user)
{
global $conf, $langs;
@ -988,7 +991,7 @@ class CommandeFournisseur extends CommonOrder
* @param string $comment Comment
* @return int <0 if KO, >0 if OK
*/
function commande($user, $date, $methode, $comment='')
public function commande($user, $date, $methode, $comment='')
{
global $langs;
dol_syslog(get_class($this)."::commande");
@ -1046,7 +1049,7 @@ class CommandeFournisseur extends CommonOrder
* @param int $notrigger Disable all triggers
* @return int <0 if KO, Id of supplier order if OK
*/
function create($user, $notrigger=0)
public function create($user, $notrigger=0)
{
global $langs,$conf,$hookmanager;
@ -1217,7 +1220,7 @@ class CommandeFournisseur extends CommonOrder
*
* @return int New id of clone
*/
function createFromClone()
public function createFromClone()
{
global $conf,$user,$langs,$hookmanager;
@ -1304,7 +1307,7 @@ class CommandeFournisseur extends CommonOrder
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int <=0 if KO, >0 if OK
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null)
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null)
{
global $langs,$mysoc,$conf;
@ -1420,77 +1423,80 @@ class CommandeFournisseur extends CommonOrder
$subprice = price2num($pu,'MU');
// TODO We should use here $this->line=new CommandeFournisseurLigne($this->db); and $this->line->insert(); to work loke other object (proposal, order, invoice)
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet";
$sql.= " (fk_commande, label, description, date_start, date_end,";
$sql.= " fk_product, product_type,";
$sql.= " qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice, ref,";
$sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_unit,";
$sql.= " fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc";
$sql.= ")";
$sql.= " VALUES (".$this->id.", '" . $this->db->escape($label) . "','" . $this->db->escape($desc) . "',";
$sql.= " ".($date_start?"'".$this->db->idate($date_start)."'":"null").",";
$sql.= " ".($date_end?"'".$this->db->idate($date_end)."'":"null").",";
if ($fk_product) { $sql.= $fk_product.","; }
else { $sql.= "null,"; }
$sql.= "'".$product_type."',";
$sql.= "'".$qty."', ".$txtva.", ".$txlocaltax1.", ".$txlocaltax2;
// Insert line
$this->line=new CommandeFournisseurLigne($this->db);
$sql.= ", '".$localtax1_type."',";
$sql.= " '".$localtax2_type."'";
$this->line->context = $this->context;
$sql.= ", ".$remise_percent.",'".price2num($subprice,'MU')."','".$ref."',";
$sql.= "'".price2num($total_ht)."',";
$sql.= "'".price2num($total_tva)."',";
$sql.= "'".price2num($total_localtax1)."',";
$sql.= "'".price2num($total_localtax2)."',";
$sql.= "'".price2num($total_ttc)."',";
$sql.= ($fk_unit ? "'".$this->db->escape($fk_unit)."'":"null");
$sql.= ", ".$this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".price2num($pu_ht * $this->multicurrency_tx);
$sql.= ", ".$multicurrency_total_ht;
$sql.= ", ".$multicurrency_total_tva;
$sql.= ", ".$multicurrency_total_ttc;
$sql.= ")";
$this->line->fk_commande=$this->id;
$this->line->label=$label;
$this->line->desc=$desc;
$this->line->qty=$qty;
$this->line->tva_tx=$txtva;
$this->line->localtax1_tx=$txlocaltax1;
$this->line->localtax2_tx=$txlocaltax2;
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->fk_product=$fk_product;
$this->line->product_type=$product_type;
$this->line->remise_percent=$remise_percent;
$this->line->subprice=$pu_ht;
$this->line->rang=$this->rang;
$this->line->info_bits=$info_bits;
$this->line->total_ht=$total_ht;
$this->line->total_tva=$total_tva;
$this->line->total_localtax1=$total_localtax1;
$this->line->total_localtax2=$total_localtax2;
$this->line->total_ttc=$total_ttc;
$this->line->product_type=$type;
$this->line->special_code=$this->special_code;
$this->line->origin=$this->origin;
$this->line->fk_unit=$fk_unit;
$resql=$this->db->query($sql);
//print $sql;
if ($resql)
$this->line->date_start=$date_start;
$this->line->date_end=$date_end;
// Multicurrency
$this->line->fk_multicurrency = $this->fk_multicurrency;
$this->line->multicurrency_code = $this->multicurrency_code;
$this->line->multicurrency_subprice = price2num($pu_ht * $this->multicurrency_tx);
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
$this->line->multicurrency_total_tva = $multicurrency_total_tva;
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
$this->line->subprice=$pu;
$this->line->price=$this->line->subprice;
$this->line->remise_percent=$remise_percent;
if (is_array($array_options) && count($array_options)>0) {
$this->line->array_options=$array_options;
}
$result=$this->line->insert($notrigger);
if ($result > 0)
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$linetmp = new CommandeFournisseurLigne($this->db);
$linetmp->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'commande_fournisseurdet');
$linetmp->array_options = $array_options;
$result=$linetmp->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
// Reorder if child line
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
if (! $error && ! $notrigger)
// Mise a jour informations denormalisees au niveau de la commande meme
$result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
if ($result > 0)
{
global $conf, $langs, $user;
// Call trigger
$result=$this->call_trigger('LINEORDER_SUPPLIER_CREATE',$user);
if ($result < 0)
{
$this->db->rollback();
return -1;
}
// End call triggers
$this->db->commit();
return $this->line->id;
}
else
{
$this->db->rollback();
return -1;
}
$this->update_price('','auto');
$this->db->commit();
return 1;
}
else
{
$this->error=$this->db->error();
$this->error=$this->line->error;
dol_syslog(get_class($this)."::addline error=".$this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
@ -1514,7 +1520,7 @@ class CommandeFournisseur extends CommonOrder
* @param int $notrigger 1 = notrigger
* @return int <0 if KO, >0 if OK
*/
function dispatchProduct($user, $product, $qty, $entrepot, $price=0, $comment='', $eatby='', $sellby='', $batch='', $fk_commandefourndet=0, $notrigger=0)
public function dispatchProduct($user, $product, $qty, $entrepot, $price=0, $comment='', $eatby='', $sellby='', $batch='', $fk_commandefourndet=0, $notrigger=0)
{
global $conf, $langs;
@ -1616,9 +1622,10 @@ class CommandeFournisseur extends CommonOrder
* @param int $notrigger 1=Disable call to triggers
* @return <0 if KO, >0 if OK
*/
function deleteline($idline, $notrigger=0)
public function deleteline($idline, $notrigger=0)
{
global $user,$langs,$conf;
$error = 0;
if ($this->statut != 0)
{
@ -1671,7 +1678,7 @@ class CommandeFournisseur extends CommonOrder
* @param User $user Object user
* @return int <0 if KO, >0 if OK
*/
function delete($user='')
public function delete($user='')
{
global $langs,$conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -1822,7 +1829,7 @@ class CommandeFournisseur extends CommonOrder
* @param int $status Filter on stats (-1 = no filter, 0 = lines draft to be approved, 1 = approved lines)
* @return array Array of lines
*/
function getDispachedLines($status=-1)
public function getDispachedLines($status=-1)
{
$ret = array();
@ -2048,7 +2055,7 @@ class CommandeFournisseur extends CommonOrder
* @param int $comclientid Id of customer order to use as template
* @return int <0 if KO, >0 if OK
*/
function updateFromCommandeClient($user, $idc, $comclientid)
public function updateFromCommandeClient($user, $idc, $comclientid)
{
$comclient = new Commande($this->db);
$comclient->fetch($comclientid);
@ -2089,7 +2096,7 @@ class CommandeFournisseur extends CommonOrder
* @param int $status New status
* @return int <0 if KO, >0 if OK
*/
function setStatus($user,$status)
public function setStatus($user,$status)
{
global $conf,$langs;
$error=0;
@ -2147,12 +2154,14 @@ class CommandeFournisseur extends CommonOrder
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int < 0 if error, > 0 if ok
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit=null)
public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit=null)
{
global $mysoc;
global $mysoc, $conf;
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
$error = 0;
if ($this->brouillon)
{
$this->db->begin();
@ -2202,83 +2211,62 @@ class CommandeFournisseur extends CommonOrder
$subprice = price2num($pu,'MU');
// Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseurdet SET";
$sql.= " description='".$this->db->escape($desc)."'";
$sql.= ",subprice='".price2num($subprice)."'";
//$sql.= ",remise='".price2num($remise)."'";
$sql.= ",remise_percent='".price2num($remise_percent)."'";
$sql.= ",tva_tx='".price2num($txtva)."'";
$sql.= ",localtax1_tx='".price2num($txlocaltax1)."'";
$sql.= ",localtax2_tx='".price2num($txlocaltax2)."'";
$sql.= ",localtax1_type='".$localtax1_type."'";
$sql.= ",localtax2_type='".$localtax2_type."'";
$sql.= ",qty='".price2num($qty)."'";
$sql.= ",date_start=".(! empty($date_start)?"'".$this->db->idate($date_start)."'":"null");
$sql.= ",date_end=".(! empty($date_end)?"'".$this->db->idate($date_end)."'":"null");
$sql.= ",info_bits='".$info_bits."'";
$sql.= ",total_ht='".price2num($total_ht)."'";
$sql.= ",total_tva='".price2num($total_tva)."'";
$sql.= ",total_localtax1='".price2num($total_localtax1)."'";
$sql.= ",total_localtax2='".price2num($total_localtax2)."'";
$sql.= ",total_ttc='".price2num($total_ttc)."'";
$sql.= ",product_type=".$type;
$sql.= ($fk_unit ? ",fk_unit='".$this->db->escape($fk_unit)."'":", fk_unit=null");
// Multicurrency
$sql.= " , multicurrency_subprice=".price2num($subprice * $this->multicurrency_tx)."";
$sql.= " , multicurrency_total_ht=".price2num($multicurrency_total_ht)."";
$sql.= " , multicurrency_total_tva=".price2num($multicurrency_total_tva)."";
$sql.= " , multicurrency_total_ttc=".price2num($multicurrency_total_ttc)."";
$sql.= " WHERE rowid = ".$rowid;
$this->line=new CommandeFournisseurLigne($this->db);
$this->line->fetch($rowid);
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result > 0)
$this->line->context = $this->context;
$this->line->fk_commande=$this->id;
//$this->line->label=$label;
$this->line->desc=$desc;
$this->line->qty=$qty;
$this->line->tva_tx=$txtva;
$this->line->localtax1_tx=$txlocaltax1;
$this->line->localtax2_tx=$txlocaltax2;
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->remise_percent=$remise_percent;
$this->line->subprice=$pu;
$this->line->rang=$this->rang;
$this->line->info_bits=$info_bits;
$this->line->total_ht=$total_ht;
$this->line->total_tva=$total_tva;
$this->line->total_localtax1=$total_localtax1;
$this->line->total_localtax2=$total_localtax2;
$this->line->total_ttc=$total_ttc;
$this->line->product_type=$type;
$this->line->special_code=$this->special_code;
$this->line->origin=$this->origin;
$this->line->fk_unit=$fk_unit;
$this->line->date_start=$date_start;
$this->line->date_end=$date_end;
// Multicurrency
$this->line->fk_multicurrency = $this->fk_multicurrency;
$this->line->multicurrency_code = $this->multicurrency_code;
$this->line->multicurrency_subprice = price2num($pu_ht * $this->multicurrency_tx);
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
$this->line->multicurrency_total_tva = $multicurrency_total_tva;
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
$this->line->subprice=$pu;
$this->line->price=$this->line->subprice;
$this->line->remise_percent=$remise_percent;
if (is_array($array_options) && count($array_options)>0) {
$this->line->array_options=$array_options;
}
$result=$this->line->update($notrigger);
// Mise a jour info denormalisees au niveau facture
if (! $error)
{
$this->rowid = $rowid;
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$tmpline = new CommandeFournisseurLigne($this->db);
$tmpline->id=$this->rowid;
$tmpline->array_options = $array_options;
$result=$tmpline->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $error && ! $notrigger)
{
global $conf, $langs, $user;
// Call trigger
$result=$this->call_trigger('LINEORDER_SUPPLIER_UPDATE',$user);
if ($result < 0)
{
$this->db->rollback();
return -1;
}
// End call triggers
}
// Mise a jour info denormalisees au niveau facture
if (! $error)
{
$this->update_price('','auto');
}
if (! $error)
{
$this->db->commit();
return $result;
}
else
{
$this->db->rollback();
return -1;
}
$this->update_price('','auto');
}
else
{
@ -2303,7 +2291,7 @@ class CommandeFournisseur extends CommonOrder
*
* @return void
*/
function initAsSpecimen()
public function initAsSpecimen()
{
global $user,$langs,$conf;
@ -2385,7 +2373,7 @@ class CommandeFournisseur extends CommonOrder
* @param int $id Id de la facture a charger
* @return void
*/
function info($id)
public function info($id)
{
$sql = 'SELECT c.rowid, date_creation as datec, tms as datem, date_valid as date_validation, date_approve as datea, date_approve2 as datea2,';
$sql.= ' fk_user_author, fk_user_modif, fk_user_valid, fk_user_approve, fk_user_approve2';
@ -2523,7 +2511,7 @@ class CommandeFournisseur extends CommonOrder
*
* @return string
*/
function getInputMethod()
public function getInputMethod()
{
global $db, $langs;
@ -2593,7 +2581,7 @@ class CommandeFournisseur extends CommonOrder
* @param Translate $langs Language object
* @return Translated string
*/
function getMaxDeliveryTimeDay($langs)
public function getMaxDeliveryTimeDay($langs)
{
if (empty($this->lines)) return '';
@ -2689,17 +2677,31 @@ class CommandeFournisseur extends CommonOrder
*/
class CommandeFournisseurLigne extends CommonOrderLine
{
public $element='commande_fournisseurdet';
public $element='commande_fournisseurdet';
public $table_element='commande_fournisseurdet';
public $oldline;
/**
* Id of parent order
* @var int
*/
public $fk_commande;
// From llx_commande_fournisseurdet
public $fk_parent_line;
public $fk_facture;
public $label;
public $rang = 0;
/**
* Unit price without taxes
* @var float
*/
public $pu_ht;
var $date_start;
var $date_end;
public $date_start;
public $date_end;
// From llx_product_fournisseur_price
@ -2715,7 +2717,9 @@ class CommandeFournisseurLigne extends CommonOrderLine
* Supplier reference
* @var string
*/
public $ref_supplier;
public $ref_supplier;
public $remise;
public $product_libelle;
/**
@ -2723,7 +2727,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
*
* @param DoliDB $db Database handler
*/
function __construct($db)
public function __construct($db)
{
$this->db= $db;
}
@ -2734,7 +2738,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
* @param int $rowid Id line order
* @return int <0 if KO, >0 if OK
*/
function fetch($rowid)
public function fetch($rowid)
{
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx,';
$sql.= ' cd.localtax1_tx, cd.localtax2_tx,';
@ -2751,6 +2755,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
{
$objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid;
$this->id = $objp->rowid;
$this->fk_commande = $objp->fk_commande;
$this->desc = $objp->description;
$this->qty = $objp->qty;
@ -2770,6 +2775,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
$this->product_type = $objp->product_type;
$this->ref = $objp->product_ref;
$this->product_ref = $objp->product_ref;
$this->product_libelle = $objp->product_libelle;
$this->product_desc = $objp->product_desc;
@ -2792,7 +2798,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
*
* @return int <0 si ko, >0 si ok
*/
function update_total()
public function updateTotal()
{
$this->db->begin();
@ -2805,7 +2811,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
$sql.= ",total_ttc='".price2num($this->total_ttc)."'";
$sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("CommandeFournisseurLigne.class.php::update_total", LOG_DEBUG);
dol_syslog(get_class($this)."::updateTotal", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
@ -2820,5 +2826,209 @@ class CommandeFournisseurLigne extends CommonOrderLine
return -2;
}
}
/**
* Insert line into database
*
* @param int $notrigger 1 = disable triggers
* @return int <0 if KO, >0 if OK
*/
public function insert($notrigger=0)
{
global $conf, $user;
$error=0;
dol_syslog(get_class($this)."::insert rang=".$this->rang);
// Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
if (empty($this->localtax1_type)) $this->localtax1_type=0;
if (empty($this->localtax2_type)) $this->localtax2_type=0;
if (empty($this->total_localtax1)) $this->total_localtax1=0;
if (empty($this->total_localtax2)) $this->total_localtax2=0;
if (empty($this->rang)) $this->rang=0;
if (empty($this->remise)) $this->remise=0;
if (empty($this->remise_percent)) $this->remise_percent=0;
if (empty($this->info_bits)) $this->info_bits=0;
if (empty($this->special_code)) $this->special_code=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->pa_ht)) $this->pa_ht=0;
// Check parameters
if ($this->product_type < 0) return -1;
$this->db->begin();
// Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " (fk_commande, label, description, date_start, date_end,";
$sql.= " fk_product, product_type,";
$sql.= " qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice, ref,";
$sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_unit,";
$sql.= " fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc";
$sql.= ")";
$sql.= " VALUES (".$this->fk_commande.", '" . $this->db->escape($this->product_label) . "','" . $this->db->escape($this->desc) . "',";
$sql.= " ".($this->date_start?"'".$this->db->idate($this->date_start)."'":"null").",";
$sql.= " ".($this->date_end?"'".$this->db->idate($this->date_end)."'":"null").",";
if ($this->fk_product) { $sql.= $this->fk_product.","; }
else { $sql.= "null,"; }
$sql.= "'".$this->product_type."',";
$sql.= "'".$this->qty."', ".$this->tva_tx.", ".$this->localtax1_tx.", ".$this->localtax2_tx;
$sql.= ", '".$this->localtax1_type."',";
$sql.= " '".$this->localtax2_type."'";
$sql.= ", ".$this->remise_percent.",'".price2num($this->subprice,'MU')."','".$this->product_ref."',";
$sql.= "'".price2num($this->total_ht)."',";
$sql.= "'".price2num($this->total_tva)."',";
$sql.= "'".price2num($this->total_localtax1)."',";
$sql.= "'".price2num($this->total_localtax2)."',";
$sql.= "'".price2num($this->total_ttc)."',";
$sql.= ($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'":"null");
$sql.= ", ".$this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".price2num($this->pu_ht * $this->multicurrency_tx);
$sql.= ", ".$this->multicurrency_total_ht;
$sql.= ", ".$this->multicurrency_total_tva;
$sql.= ", ".$this->multicurrency_total_ttc;
$sql.= ")";
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
$this->rowid =$this->id;
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('LINEORDER_INSERT',$user);
if ($result < 0) $error++;
// End call triggers
}
if (!$error) {
$this->db->commit();
return 1;
}
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->errors[]=($this->errors?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->errors[]=$this->db->error();
$this->db->rollback();
return -2;
}
}
/**
* Update the line object into db
*
* @param int $notrigger 1 = disable triggers
* @return int <0 si ko, >0 si ok
*/
public function update($notrigger=0)
{
global $conf,$user;
$error=0;
// Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
$sql.= " description='".$this->db->escape($this->desc)."'";
$sql.= ",subprice='".price2num($this->subprice)."'";
//$sql.= ",remise='".price2num($remise)."'";
$sql.= ",remise_percent='".price2num($this->remise_percent)."'";
$sql.= ",tva_tx='".price2num($this->tva_tx)."'";
$sql.= ",localtax1_tx='".price2num($this->total_localtax1)."'";
$sql.= ",localtax2_tx='".price2num($this->total_localtax2)."'";
$sql.= ",localtax1_type='".$this->localtax1_type."'";
$sql.= ",localtax2_type='".$this->localtax2_type."'";
$sql.= ",qty='".price2num($this->qty)."'";
$sql.= ",date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null");
$sql.= ",date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
$sql.= ",info_bits='".$this->info_bits."'";
$sql.= ",total_ht='".price2num($this->total_ht)."'";
$sql.= ",total_tva='".price2num($this->total_tva)."'";
$sql.= ",total_localtax1='".price2num($this->total_localtax1)."'";
$sql.= ",total_localtax2='".price2num($this->total_localtax2)."'";
$sql.= ",total_ttc='".price2num($this->total_ttc)."'";
$sql.= ",product_type=".$this->product_type;
$sql.= ($this->fk_unit ? ",fk_unit='".$this->db->escape($this->fk_unit)."'":", fk_unit=null");
// Multicurrency
$sql.= " , multicurrency_subprice=".price2num($this->subprice * $this->multicurrency_tx)."";
$sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht)."";
$sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva)."";
$sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc)."";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result > 0)
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $error && ! $notrigger)
{
global $user;
// Call trigger
$result=$this->call_trigger('LINEORDER_SUPPLIER_UPDATE',$user);
if ($result < 0)
{
$this->db->rollback();
return -1;
}
// End call triggers
}
if (! $error)
{
$this->db->commit();
return $result;
}
else
{
$this->db->rollback();
return -1;
}
}
else
{
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
}
}
}

View File

@ -50,57 +50,57 @@ class FactureFournisseur extends CommonInvoice
*/
protected $table_ref_field = 'ref';
var $rowid;
var $ref;
var $product_ref;
var $ref_supplier;
var $socid;
public $rowid;
public $ref;
public $product_ref;
public $ref_supplier;
public $socid;
//Check constants for types
var $type = self::TYPE_STANDARD;
public $type = self::TYPE_STANDARD;
/**
* Supplier invoice status
* @var int
* @see FactureFournisseur::STATUS_DRAFT, FactureFournisseur::STATUS_VALIDATED, FactureFournisseur::STATUS_PAID, FactureFournisseur::STATUS_ABANDONED
*/
var $statut;
public $statut;
/**
* Set to 1 if the invoice is completely paid, otherwise is 0
* @var int
* @deprecated Use statuses stored in self::statut
*/
var $paye;
public $paye;
var $author;
var $libelle;
var $datec; // Creation date
var $tms; // Last update date
var $date; // Invoice date
var $date_echeance; // Max payment date
var $amount;
var $remise;
var $tva;
var $localtax1;
var $localtax2;
var $total_ht;
var $total_tva;
var $total_localtax1;
var $total_localtax2;
var $total_ttc;
public $author;
public $libelle;
public $datec; // Creation date
public $tms; // Last update date
public $date; // Invoice date
public $date_echeance; // Max payment date
public $amount;
public $remise;
public $tva;
public $localtax1;
public $localtax2;
public $total_ht;
public $total_tva;
public $total_localtax1;
public $total_localtax2;
public $total_ttc;
/**
* @deprecated
* @see note_private, note_public
*/
var $note;
var $note_private;
var $note_public;
var $propalid;
var $cond_reglement_id;
var $cond_reglement_code;
var $fk_account;
var $mode_reglement_id;
var $mode_reglement_code;
public $note;
public $note_private;
public $note_public;
public $propalid;
public $cond_reglement_id;
public $cond_reglement_code;
public $fk_account;
public $mode_reglement_id;
public $mode_reglement_code;
/**
* Invoice lines
@ -110,29 +110,29 @@ class FactureFournisseur extends CommonInvoice
/**
* @deprecated
*/
var $fournisseur;
public $fournisseur;
//Incorterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
public $fk_incoterms;
public $location_incoterms;
public $libelle_incoterms; //Used into tooltip
var $extraparams=array();
public $extraparams=array();
// Multicurrency
var $fk_multicurrency;
var $multicurrency_code;
var $multicurrency_tx;
var $multicurrency_total_ht;
var $multicurrency_total_tva;
var $multicurrency_total_ttc;
public $fk_multicurrency;
public $multicurrency_code;
public $multicurrency_tx;
public $multicurrency_total_ht;
public $multicurrency_total_tva;
public $multicurrency_total_ttc;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
public function __construct($db)
{
$this->db = $db;
@ -155,7 +155,7 @@ class FactureFournisseur extends CommonInvoice
* @param User $user object utilisateur qui cree
* @return int id facture si ok, < 0 si erreur
*/
function create($user)
public function create($user)
{
global $langs,$conf,$hookmanager;
@ -355,7 +355,7 @@ class FactureFournisseur extends CommonInvoice
* @param string $ref Ref supplier invoice
* @return int <0 if KO, >0 if OK, 0 if not found
*/
function fetch($id='',$ref='')
public function fetch($id='',$ref='')
{
global $langs;
@ -613,7 +613,7 @@ class FactureFournisseur extends CommonInvoice
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user=null, $notrigger=0)
public function update($user=null, $notrigger=0)
{
global $conf, $langs;
$error=0;
@ -741,7 +741,7 @@ class FactureFournisseur extends CommonInvoice
* @param int $rowid Id of invoice to delete
* @return int <0 if KO, >0 if OK
*/
function delete($rowid)
public function delete($rowid)
{
global $user,$langs,$conf;
@ -955,7 +955,7 @@ class FactureFournisseur extends CommonInvoice
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, =0 if nothing to do, >0 if OK
*/
function validate($user, $force_number='', $idwarehouse=0, $notrigger=0)
public function validate($user, $force_number='', $idwarehouse=0, $notrigger=0)
{
global $conf,$langs;
@ -1011,6 +1011,7 @@ class FactureFournisseur extends CommonInvoice
{
if ($this->lines[$i]->fk_product > 0)
{
$this->line = $this->lines[$i];
$mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
// We increase stock for product
@ -1018,6 +1019,7 @@ class FactureFournisseur extends CommonInvoice
if (! empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc=price2num($up_ht_disc * (100 - $this->lines[$i]->remise_percent) / 100, 'MU');
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("InvoiceValidatedInDolibarr",$num));
if ($result < 0) { $error++; }
unset($this->line);
}
}
}
@ -1194,14 +1196,16 @@ class FactureFournisseur extends CommonInvoice
* @param int $notrigger Disable triggers
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @param int $origin_id id origin document
* @return int >0 if OK, <0 if KO
*
* FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order.
*/
function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null)
public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0)
{
dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
global $mysoc;
// Clean parameters
if (empty($remise_percent)) $remise_percent=0;
@ -1220,52 +1224,92 @@ class FactureFournisseur extends CommonInvoice
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc, $this->thirdparty);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
$total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10];
// MultiCurrency
$multicurrency_total_ht = $tabprice[16];
$multicurrency_total_tva = $tabprice[17];
$multicurrency_total_ttc = $tabprice[18];
// Check parameters
if ($type < 0) return -1;
// Insert line
$this->line=new SupplierInvoiceLine($this->db);
$this->db->begin();
$this->line->context = $this->context;
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)';
$sql.= ' VALUES ('.$this->id.')';
dol_syslog(get_class($this)."::addline", LOG_DEBUG);
$this->line->fk_facture_fourn=$this->id;
//$this->line->label=$label; // deprecated
$this->line->desc=$desc;
$this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
$this->line->tva_tx=$txtva;
$this->line->localtax1_tx=$txlocaltax1;
$this->line->localtax2_tx=$txlocaltax2;
$this->line->fk_product=$fk_product;
$this->line->product_type=$type;
$this->line->remise_percent=$remise_percent;
$this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu):$pu); // For credit note, unit price always negative, always positive otherwise
$this->line->date_start=$date_start;
$this->line->date_end=$date_end;
$this->line->ventil=$ventil;
$this->line->rang=$rang;
$this->line->info_bits=$info_bits;
$this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative
$this->line->total_tva= $total_tva;
$this->line->total_localtax1=$total_localtax1;
$this->line->total_localtax2=$total_localtax2;
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc);
$this->line->special_code=$this->special_code;
$this->line->fk_parent_line=$this->fk_parent_line;
$this->line->origin=$this->origin;
$this->line->origin_id=$origin_id;
$this->line->fk_unit=$fk_unit;
$resql = $this->db->query($sql);
if ($resql)
// Multicurrency
$this->line->fk_multicurrency = $this->fk_multicurrency;
$this->line->multicurrency_code = $this->multicurrency_code;
$this->line->multicurrency_subprice = price2num($this->line->subprice * $this->multicurrency_tx);
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
$this->line->multicurrency_total_tva = $multicurrency_total_tva;
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
if (is_array($array_options) && count($array_options)>0) {
$this->line->array_options=$array_options;
}
$result=$this->line->insert($notrigger);
if ($result > 0)
{
$idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det');
// Reorder if child line
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
$result=$this->updateline($idligne, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product, $price_base_type, $info_bits, $type, $remise_percent, true, '', '', $array_options, $fk_unit);
// Mise a jour informations denormalisees au niveau de la facture meme
$result=$this->update_price(1,'auto',0,$mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode.
if ($result > 0)
{
$this->rowid = $idligne;
if (! $notrigger)
{
global $conf, $langs, $user;
// Call trigger
$result=$this->call_trigger('LINEBILL_SUPPLIER_CREATE',$user);
if ($result < 0)
{
$this->db->rollback();
return -1;
}
// End call triggers
}
$this->db->commit();
return 1;
return $this->line->id;
}
else
{
dol_syslog("Error after updateline error=".$this->error, LOG_ERR);
$this->error=$this->db->error();
$this->db->rollback();
return -1;
}
}
else
{
$this->error=$this->db->lasterror();
$this->error=$this->line->error;
$this->db->rollback();
return -2;
}
@ -1293,7 +1337,7 @@ class FactureFournisseur extends CommonInvoice
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int <0 if KO, >0 if OK
*/
function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null)
public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null)
{
global $mysoc;
dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$fk_unit", LOG_DEBUG);
@ -1315,6 +1359,8 @@ class FactureFournisseur extends CommonInvoice
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
$localtaxes_type = array($txlocaltax1,$txlocaltax2);
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
@ -1404,7 +1450,7 @@ class FactureFournisseur extends CommonInvoice
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, >0 if OK
*/
function deleteline($rowid, $notrigger=0)
public function deleteline($rowid, $notrigger=0)
{
if (!$rowid) {
$rowid = $this->id;
@ -1434,7 +1480,7 @@ class FactureFournisseur extends CommonInvoice
* @param int $id Id de la facture a charger
* @return void
*/
function info($id)
public function info($id)
{
$sql = 'SELECT c.rowid, datec, tms as datem, ';
$sql.= ' fk_user_author, fk_user_modif, fk_user_valid';
@ -1543,9 +1589,9 @@ class FactureFournisseur extends CommonInvoice
* @param int $max Max length of shown ref
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='',$max=0)
public function getNomUrl($withpicto=0,$option='',$max=0)
{
global $langs;
global $langs, $conf;
$result='';
$label = '<u>' . $langs->trans("ShowSupplierInvoice") . '</u>';
@ -1587,7 +1633,7 @@ class FactureFournisseur extends CommonInvoice
* @param string $mode 'next' for next value or 'last' for last value
* @return string free ref or last ref
*/
function getNextNumRef($soc,$mode='next')
public function getNextNumRef($soc,$mode='next')
{
global $db, $langs, $conf;
$langs->load("orders");
@ -1640,7 +1686,7 @@ class FactureFournisseur extends CommonInvoice
*
* @return void
*/
function initAsSpecimen()
public function initAsSpecimen()
{
global $langs,$conf;
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@ -1780,7 +1826,7 @@ class FactureFournisseur extends CommonInvoice
* @param int $invertdetail Reverse sign of amounts for lines
* @return int New id of clone
*/
function createFromClone($fromid,$invertdetail=0)
public function createFromClone($fromid,$invertdetail=0)
{
global $user,$langs;
@ -1942,7 +1988,7 @@ class SupplierInvoiceLine extends CommonObjectLine
public $element='facture_fourn_det';
public $table_element='facture_fourn_det';
var $oldline;
public $oldline;
/**
* @deprecated
@ -1999,22 +2045,22 @@ class SupplierInvoiceLine extends CommonObjectLine
* Id of the corresponding supplier invoice
* @var int
*/
var $fk_facture_fourn;
public $fk_facture_fourn;
/**
* Product label
* This field may contains label of product (when invoice create from order)
* @var string
*/
var $label;
public $label;
/**
* Description of the line
* @var string
*/
var $description;
public $description;
var $skip_update_total; // Skip update price total for special lines
public $skip_update_total; // Skip update price total for special lines
/**
* @var int Situation advance percentage
@ -2046,19 +2092,19 @@ class SupplierInvoiceLine extends CommonObjectLine
public $localtax2_type;
// Multicurrency
var $fk_multicurrency;
var $multicurrency_code;
var $multicurrency_subprice;
var $multicurrency_total_ht;
var $multicurrency_total_tva;
var $multicurrency_total_ttc;
public $fk_multicurrency;
public $multicurrency_code;
public $multicurrency_subprice;
public $multicurrency_total_ht;
public $multicurrency_total_tva;
public $multicurrency_total_ttc;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
public function __construct($db)
{
$this->db= $db;
}
@ -2292,5 +2338,146 @@ class SupplierInvoiceLine extends CommonObjectLine
$this->db->commit();
return 1;
}
/**
* Insert line into database
*
* @param int $notrigger 1 no triggers
* @return int <0 if KO, >0 if OK
*/
public function insert($notrigger=0)
{
global $user,$conf;
$error=0;
dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG);
// Clean parameters
$this->desc=trim($this->desc);
if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
if (empty($this->localtax1_type)) $this->localtax1_type=0;
if (empty($this->localtax2_type)) $this->localtax2_type=0;
if (empty($this->total_localtax1)) $this->total_localtax1=0;
if (empty($this->total_localtax2)) $this->total_localtax2=0;
if (empty($this->rang)) $this->rang=0;
if (empty($this->remise_percent)) $this->remise_percent=0;
if (empty($this->info_bits)) $this->info_bits=0;
if (empty($this->subprice)) $this->subprice=0;
if (empty($this->special_code)) $this->special_code=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100;
if (empty($this->pa_ht)) $this->pa_ht=0;
if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0;
if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0;
if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0;
if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0;
// Check parameters
if ($this->product_type < 0)
{
$this->error='ErrorProductTypeMustBe0orMore';
return -1;
}
if (! empty($this->fk_product))
{
// Check product exists
$result=Product::isExistingObject('product', $this->fk_product);
if ($result <= 0)
{
$this->error='ErrorProductIdDoesNotExists';
return -1;
}
}
$this->db->begin();
// Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
$sql.= ' (fk_facture_fourn, fk_parent_line, label, description, qty,';
$sql.= ' tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
$sql.= ' fk_product, product_type, remise_percent, pu_ht, pu_ttc,';
$sql.= ' date_start, date_end, fk_code_ventilation, rang, special_code,';
$sql.= ' info_bits, total_ht, tva, total_ttc, total_localtax1, total_localtax2, fk_unit';
$sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
$sql.= ')';
$sql.= " VALUES (".$this->fk_facture_fourn.",";
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " '".$this->db->escape($this->desc)."',";
$sql.= " ".price2num($this->qty).",";
$sql.= " ".price2num($this->tva_tx).",";
$sql.= " ".price2num($this->localtax1_tx).",";
$sql.= " ".price2num($this->localtax2_tx).",";
$sql.= " '".$this->localtax1_type."',";
$sql.= " '".$this->localtax2_type."',";
$sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").',';
$sql.= " ".$this->product_type.",";
$sql.= " ".price2num($this->remise_percent).",";
$sql.= " ".price2num($this->subprice).",";
$sql.= " ".price2num($this->total_ttc/$this->qty).",";
$sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").",";
$sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").",";
$sql.= ' '.(!empty($this->fk_code_ventilation)?$this->fk_code_ventilation:0).',';
$sql.= ' '.$this->rang.',';
$sql.= ' '.$this->special_code.',';
$sql.= " '".$this->info_bits."',";
$sql.= " ".price2num($this->total_ht).",";
$sql.= " ".price2num($this->total_tva).",";
$sql.= " ".price2num($this->total_ttc).",";
$sql.= " ".price2num($this->total_localtax1).",";
$sql.= " ".price2num($this->total_localtax2);
$sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= ", ".(int) $this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".price2num($this->multicurrency_subprice);
$sql.= ", ".price2num($this->multicurrency_total_ht);
$sql.= ", ".price2num($this->multicurrency_total_tva);
$sql.= ", ".price2num($this->multicurrency_total_ttc);
$sql.= ')';
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
$this->rowid=$this->id;
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('LINEBILL_SUPPLIER_CREATE',$user);
if ($result < 0)
{
$this->db->rollback();
return -2;
}
// End call triggers
}
$this->db->commit();
return $this->id;
}
else
{
$this->error=$this->db->error();
$this->db->rollback();
return -2;
}
}
}

View File

@ -476,7 +476,8 @@ if (empty($reshook))
$lines[$i]->rang,
0,
$lines[$i]->array_options,
$lines[$i]->fk_unit
$lines[$i]->fk_unit,
$lines[$i]->id
);
if ($result < 0)

View File

@ -1,11 +1,11 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013-2014 Juanjo Menent <jmenent@2byte.es>
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,6 +28,8 @@
*/
include_once 'inc.php';
global $langs;
$err = 0;
$allowinstall = 0;
$allowupgrade = false;
@ -42,7 +44,10 @@ $langs->load("install");
$useforcedwizard=false;
$forcedfile="./install.forced.php";
if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php";
if (@file_exists($forcedfile)) { $useforcedwizard=true; include_once $forcedfile; }
if (@file_exists($forcedfile)) {
$useforcedwizard = true;
include_once $forcedfile;
}
dolibarr_install_syslog("--- check: Dolibarr install/upgrade process started");

View File

@ -1,10 +1,11 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,6 +29,8 @@
include_once 'inc.php';
global $langs;
$err=0;
$setuplang=GETPOST("selectlang",'',3)?GETPOST("selectlang",'',3):(isset($_GET["lang"])?$_GET["lang"]:'auto');
@ -58,12 +61,10 @@ $useforcedwizard=false;
$forcedfile="./install.forced.php";
if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; // Must be after inc.php
if (@file_exists($forcedfile)) {
$useforcedwizard=true; include_once $forcedfile;
$useforcedwizard = true;
include_once $forcedfile;
}
//$force_install_message='This is the message';
//$force_install_noedit=1;
/*
* View
@ -120,37 +121,20 @@ if (! empty($force_install_message))
print $langs->trans("WebPagesDirectory");
print "</b></td>";
if(! isset($dolibarr_main_url_root) || dol_strlen($dolibarr_main_url_root) == 0)
{
//print "x".$_SERVER["SCRIPT_FILENAME"]." y".$_SERVER["DOCUMENT_ROOT"];
// Si le php fonctionne en CGI, alors SCRIPT_FILENAME vaut le path du php et
// ce n'est pas ce qu'on veut. Dans ce cas, on propose $_SERVER["DOCUMENT_ROOT"]
if (preg_match('/^php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/[\\/]php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i',$_SERVER["SCRIPT_FILENAME"]))
{
$dolibarr_main_document_root=$_SERVER["DOCUMENT_ROOT"];
if (! preg_match('/[\\/]dolibarr[\\/]htdocs$/i',$dolibarr_main_document_root))
{
$dolibarr_main_document_root.="/dolibarr/htdocs";
}
}
else
{
$dolibarr_main_document_root = substr($_SERVER["SCRIPT_FILENAME"],0,dol_strlen($_SERVER["SCRIPT_FILENAME"]) - 21);
// Nettoyage du path propose
// Gere les chemins windows avec double "\"
$dolibarr_main_document_root = str_replace('\\\\','/',$dolibarr_main_document_root);
// Supprime les slash ou antislash de fins
$dolibarr_main_document_root = preg_replace('/[\\/]+$/','',$dolibarr_main_document_root);
}
if (empty($dolibarr_main_url_root)) {
$dolibarr_main_document_root = detect_dolibarr_main_document_root();
}
?>
<td class="label" valign="top"><?php
if ($force_install_noedit) print '<input type="hidden" value="'.$dolibarr_main_document_root.'" name="main_dir">';
print '<input type="text" size="60" value="'.$dolibarr_main_document_root.'"'.(empty($force_install_noedit)?'':' disabled').' name="main_dir'.(empty($force_install_noedit)?'':'_bis').'">';
?></td>
<td class="label" valign="top">
<input type="text"
size="60"
value="<?php print $dolibarr_main_document_root ?>"
name="main_dir"
<?php if (!empty($force_install_noedit)) {
print 'disabled';
} ?>
>
</td>
<td class="comment"><?php
print $langs->trans("WithNoSlashAtTheEnd")."<br>";
print $langs->trans("Examples").":<br>";
@ -167,24 +151,21 @@ if (! empty($force_install_message))
<td valign="top" class="label"><b> <?php print $langs->trans("DocumentsDirectory"); ?></b>
</td>
<?php
if (empty($dolibarr_main_data_root))
{
// Si le repertoire documents non defini, on en propose un par defaut
if (empty($force_install_main_data_root))
{
$dolibarr_main_data_root=preg_replace("/\/htdocs$/","",$dolibarr_main_document_root);
$dolibarr_main_data_root.="/documents";
}
else
{
$dolibarr_main_data_root=$force_install_main_data_root;
}
$dolibarr_main_data_root = $force_install_main_data_root;
if (empty($dolibarr_main_data_root)) {
$dolibarr_main_data_root = detect_dolibarr_main_data_root($dolibarr_main_document_root);
}
?>
<td class="label" valign="top"><?php
if ($force_install_noedit) print '<input type="hidden" value="'.$dolibarr_main_data_root.'" name="main_data_dir">';
print '<input type="text" size="60" value="'.$dolibarr_main_data_root.'"'.(empty($force_install_noedit)?'':' disabled').' name="main_data_dir'.(empty($force_install_noedit)?'':'_bis').'">';
?></td>
<td class="label" valign="top">
<input type="text"
size="60"
value="<?php print $dolibarr_main_data_root ?>"
name="main_data_dir"
<?php if (!empty($force_install_noedit)) {
print 'disabled';
} ?>
>
</td>
<td class="comment"><?php
print $langs->trans("WithNoSlashAtTheEnd")."<br>";
print $langs->trans("DirectoryRecommendation")."<br>";
@ -199,39 +180,23 @@ if (! empty($force_install_message))
<!-- Root URL $dolibarr_main_url_root -->
<?php
if (! empty($main_url)) $dolibarr_main_url_root=$main_url;
if (empty($dolibarr_main_url_root))
{
// If defined (Ie: Apache with Linux)
if (isset($_SERVER["SCRIPT_URI"])) {
$dolibarr_main_url_root=$_SERVER["SCRIPT_URI"];
}
// If defined (Ie: Apache with Caudium)
elseif (isset($_SERVER["SERVER_URL"]) && isset($_SERVER["DOCUMENT_URI"])) {
$dolibarr_main_url_root=$_SERVER["SERVER_URL"].$_SERVER["DOCUMENT_URI"];
}
// If SCRIPT_URI, SERVER_URL, DOCUMENT_URI not defined (Ie: Apache 2.0.44 for Windows)
else
{
$proto='http';
if (! empty($_SERVER["HTTP_HOST"])) $serverport=$_SERVER["HTTP_HOST"];
else $serverport=$_SERVER["SERVER_NAME"];
$dolibarr_main_url_root=$proto."://".$serverport.$_SERVER["SCRIPT_NAME"];
}
// Clean proposed URL
$dolibarr_main_url_root = preg_replace('/\/fileconf\.php$/','',$dolibarr_main_url_root); // Remove the /fileconf.php
$dolibarr_main_url_root = preg_replace('/\/$/','',$dolibarr_main_url_root); // Remove the /
$dolibarr_main_url_root = preg_replace('/\/index\.php$/','',$dolibarr_main_url_root); // Remove the /index.php
$dolibarr_main_url_root = preg_replace('/\/install$/','',$dolibarr_main_url_root); // Remove the /install
if (empty($dolibarr_main_url_root)) {
$dolibarr_main_url_root = detect_dolibarr_main_url_root();
}
?>
<tr>
<td valign="top" class="label"><b> <?php echo $langs->trans("URLRoot"); ?></b>
</td>
<td valign="top" class="label"><?php
if ($force_install_noedit) print '<input type="hidden" value="'.$dolibarr_main_url_root.'" name="main_url">';
print '<input type="text" size="60" value="'.$dolibarr_main_url_root.'"'.(empty($force_install_noedit)?'':' disabled').' name="main_url'.(empty($force_install_noedit)?'':'_bis').'">';
?></td>
<td valign="top" class="label">
<input type="text"
size="60"
name="main_url"
value="<?php print $dolibarr_main_url_root; ?> "
<?php if (!empty($force_install_noedit)) {
print 'disabled';
} ?>
>
</td>
<td class="comment"><?php print $langs->trans("Examples").":<br>"; ?>
<ul>
<li>http://localhost/</li>
@ -245,9 +210,17 @@ if (! empty($force_install_message))
?>
<tr>
<td valign="top" class="label"><?php echo $langs->trans("ForceHttps"); ?></td>
<td class="label" valign="top"><input type="checkbox"
name="main_force_https"
<?php if (! empty($force_install_mainforcehttps)) print ' checked'; ?>></td>
<td class="label" valign="top">
<input type="checkbox"
name="main_force_https"
<?php if (!empty($force_install_mainforcehttps)) {
print 'checked';
} ?>
<?php if ($force_install_noedit == 2 && $force_install_mainforcehttps !== null) {
print 'disabled';
} ?>
>
</td>
<td class="comment"><?php echo $langs->trans("CheckToForceHttps"); ?>
</td>
@ -265,13 +238,18 @@ if (! empty($force_install_message))
</tr>
<tr>
<td class="label" valign="top"><b> <?php echo $langs->trans("DatabaseName"); ?>
</b></td>
<td class="label" valign="top"><input type="text" id="db_name"
name="db_name"
value="<?php echo (! empty($dolibarr_main_db_name))?$dolibarr_main_db_name:($force_install_database?$force_install_database:'dolibarr'); ?>"></td>
<td class="comment"><?php echo $langs->trans("DatabaseName"); ?></td>
<td class="label" valign="top"><b> <?php echo $langs->trans("DatabaseName"); ?>
</b></td>
<td class="label" valign="top">
<input type="text" id="db_name"
name="db_name"
value="<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
<?php if ($force_install_noedit == 2 && $force_install_database !== null) {
print 'disabled';
} ?>
>
</td>
<td class="comment"><?php echo $langs->trans("DatabaseName"); ?></td>
</tr>
@ -286,7 +264,8 @@ if (! empty($force_install_message))
<td valign="top" class="label"><b> <?php echo $langs->trans("DriverType"); ?>
</b></td>
<td class="label"><?php
<td class="label">
<?php
$defaultype=! empty($dolibarr_main_db_type)?$dolibarr_main_db_type:($force_install_type?$force_install_type:'mysqli');
@ -342,13 +321,17 @@ if (! empty($force_install_message))
}
}
}
?>
<select id="db_type"
name="db_type"
<?php if ($force_install_noedit && $force_install_type !== null) {
print 'disabled';
} ?>
>
<?php print $option; ?>
</select>
if ($force_install_noedit && $force_install_type) print '<input id="db_type" type="hidden" value="'.$force_install_type.'" name="db_type">';
print '<select id="db_type" name="db_type'.(empty($force_install_noedit) || empty($force_install_type)?'':'_bis').'"'.($force_install_noedit && $force_install_type?' disabled':'').'>';
print $option;
print '</select>';
?></td>
</td>
<td class="comment"><?php echo $langs->trans("DatabaseType"); ?></td>
</tr>
@ -356,11 +339,14 @@ if (! empty($force_install_message))
<tr class="hidesqlite">
<td valign="top" class="label"><b> <?php echo $langs->trans("Server"); ?>
</b></td>
<td valign="top" class="label"><input type="text"
name="db_host<?php print ($force_install_noedit==2 && $force_install_dbserver)?'_bis':''; ?>"
<?php if ($force_install_noedit==2 && $force_install_dbserver) print ' disabled'; ?>
value="<?php print (! empty($dolibarr_main_db_host))?$dolibarr_main_db_host:(empty($force_install_dbserver)?'localhost':$force_install_dbserver); ?>">
<?php if ($force_install_noedit==2 && $force_install_dbserver) print '<input type="hidden" name="db_host" value="'.((! empty($dolibarr_main_db_host))?$dolibarr_main_db_host:$force_install_dbserver).'">'; ?>
<td valign="top" class="label">
<input type="text"
name="db_host"
value="<?php print (!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
<?php if ($force_install_noedit == 2 && $force_install_dbserver !== null) {
print ' disabled';
} ?>
>
</td>
<td class="comment"><?php echo $langs->trans("ServerAddressDescription"); ?>
</td>
@ -369,11 +355,15 @@ if (! empty($force_install_message))
<tr class="hidesqlite">
<td valign="top" class="label"><?php echo $langs->trans("Port"); ?></td>
<td valign="top" class="label"><input type="text" id="db_port"
name="db_port<?php print ($force_install_noedit==2 && $force_install_port)?'_bis':''; ?>"
<?php if ($force_install_noedit==2 && $force_install_port) print ' disabled'; ?>
value="<?php print (! empty($dolibarr_main_db_port))?$dolibarr_main_db_port:$force_install_port; ?>">
<?php if ($force_install_noedit==2 && $force_install_port) print '<input type="hidden" name="db_port" value="'.((! empty($dolibarr_main_db_port))?$dolibarr_main_db_port:$force_install_port).'">'; ?>
<td valign="top" class="label">
<input type="text"
name="db_port"
id="db_port"
value="<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>"
<?php if ($force_install_noedit == 2 && $force_install_port !== null) {
print ' disabled';
} ?>
>
</td>
<td class="comment"><?php echo $langs->trans("ServerPortDescription"); ?>
</td>
@ -383,20 +373,33 @@ if (! empty($force_install_message))
<tr class="hidesqlite">
<td class="label" valign="top"><?php echo $langs->trans("DatabasePrefix"); ?>
</td>
<td class="label" valign="top"><input type="text" id="db_prefix"
name="db_prefix"
value="<?php echo (! empty($dolibarr_main_db_prefix))?$dolibarr_main_db_prefix:($force_install_prefix?$force_install_prefix:'llx_'); ?>"></td>
<td class="label" valign="top">
<input type="text" id="db_prefix"
name="db_prefix"
value="<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
<?php if ($force_install_noedit == 2 && $force_install_prefix !== null) {
print ' disabled';
} ?>
>
</td>
<td class="comment"><?php echo $langs->trans("DatabasePrefix"); ?></td>
</tr>
<tr class="hidesqlite">
<td class="label" valign="top"><?php echo $langs->trans("CreateDatabase"); ?>
</td>
<td class="label" valign="top"><input type="checkbox"
id="db_create_database" name="db_create_database"
<?php if ($force_install_createdatabase) print ' checked'; ?>></td>
<td class="label" valign="top">
<input type="checkbox"
id="db_create_database"
name="db_create_database"
<?php if ($force_install_createdatabase) {
print ' checked';
} ?>
<?php if ($force_install_noedit == 2 && $force_install_createdatabase !== null) {
print ' disabled';
} ?>
>
</td>
<td class="comment"><?php echo $langs->trans("CheckToCreateDatabase"); ?>
</td>
</tr>
@ -404,33 +407,54 @@ if (! empty($force_install_message))
<tr class="hidesqlite">
<td class="label" valign="top"><b><?php echo $langs->trans("Login"); ?></b>
</td>
<td class="label" valign="top"><input type="text" id="db_user"
name="db_user"
value="<?php print (! empty($dolibarr_main_db_user))?$dolibarr_main_db_user:$force_install_databaselogin; ?>"></td>
<td class="label" valign="top">
<input type="text" id="db_user"
name="db_user"
value="<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
<?php if ($force_install_noedit == 2 && $force_install_databaselogin !== null) {
print ' disabled';
} ?>
>
</td>
<td class="comment"><?php echo $langs->trans("AdminLogin"); ?></td>
</tr>
<tr class="hidesqlite">
<td class="label" valign="top"><b><?php echo $langs->trans("Password"); ?></b>
</td>
<td class="label" valign="top"><input type="password" id="db_pass" autocomplete="off"
name="db_pass"
value="<?php
//$autofill=((! empty($dolibarr_main_db_pass))?$dolibarr_main_db_pass:$force_install_databasepass);
$autofill=((! empty($_SESSION['dol_save_pass']))?$_SESSION['dol_save_pass']:$force_install_databasepass);
if (! empty($dolibarr_main_prod)) $autofill='';
print dol_escape_htmltag($autofill);
?>"></td>
<td class="label" valign="top">
<input type="password" id="db_pass" autocomplete="off"
name="db_pass"
value="<?php
// We don't want to set password. It will be extracted from the forced install file at step1.
$autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : '');
if (!empty($dolibarr_main_prod)) {
$autofill = '';
}
print dol_escape_htmltag($autofill);
?>"
<?php if ($force_install_noedit == 2 && $force_install_databasepass !== null) {
print 'disabled';
} ?>
>
</td>
<td class="comment"><?php echo $langs->trans("AdminPassword"); ?></td>
</tr>
<tr class="hidesqlite">
<td class="label" valign="top"><?php echo $langs->trans("CreateUser"); ?>
</td>
<td class="label" valign="top"><input type="checkbox"
id="db_create_user" name="db_create_user"
<?php if (! empty($force_install_createuser)) print ' checked'; ?>></td>
<td class="label" valign="top">
<input type="checkbox"
id="db_create_user" name="db_create_user"
<?php if (!empty($force_install_createuser)) {
print 'checked';
} ?>
<?php if ($force_install_noedit == 2 && $force_install_createuser !== null) {
print 'disabled';
} ?>
>
</td>
<td class="comment"><?php echo $langs->trans("CheckToCreateUser"); ?>
</td>
</tr>
@ -438,8 +462,8 @@ if (! empty($force_install_message))
<!-- Super access -->
<?php
$force_install_databaserootlogin=preg_replace('/__SUPERUSERLOGIN__/','root',$force_install_databaserootlogin);
$force_install_databaserootpass=preg_replace('/__SUPERUSERPASSWORD__/','',$force_install_databaserootpass);
$force_install_databaserootlogin = parse_database_login($force_install_databaserootlogin);
$force_install_databaserootpass = parse_database_pass($force_install_databaserootpass);
?>
<tr class="hidesqlite hideroot">
<td colspan="3" class="label" align="center"><br>
@ -449,9 +473,17 @@ if (! empty($force_install_message))
<tr class="hidesqlite hideroot">
<td class="label" valign="top"><b><?php echo $langs->trans("Login"); ?></b></td>
<td class="label" valign="top"><input type="text" id="db_user_root"
name="db_user_root" class="needroot"
value="<?php print (! empty($db_user_root))?$db_user_root:$force_install_databaserootlogin; ?>"></td>
<td class="label" valign="top">
<input type="text"
id="db_user_root"
name="db_user_root"
class="needroot"
value="<?php print (!empty($force_install_databaserootlogin)) ? $force_install_databaserootlogin : $db_user_root; ?>"
<?php if ($force_install_noedit == 2 && $force_install_databaserootlogin !== null) {
print 'disabled';
} ?>
>
</td>
<td class="comment"><?php echo $langs->trans("DatabaseRootLoginDescription"); ?>
<!--
<?php echo '<br>'.$langs->trans("Examples").':<br>' ?>
@ -466,14 +498,30 @@ if (! empty($force_install_message))
<tr class="hidesqlite hideroot">
<td class="label" valign="top"><b><?php echo $langs->trans("Password"); ?></b>
</td>
<td class="label" valign="top"><input type="password" autocomplete="off"
id="db_pass_root" name="db_pass_root" class="needroot"
value="<?php
$autofill=((! empty($db_pass_root))?$db_pass_root:$force_install_databaserootpass);
if (! empty($dolibarr_main_prod)) $autofill=''; // Do not autofill password if instance is a production instance
if (! empty($_SERVER["SERVER_NAME"]) && ! in_array($_SERVER["SERVER_NAME"], array('127.0.0.1', 'localhost'))) $autofill=''; // Do not autofill password for remote access
print dol_escape_htmltag($autofill);
?>"></td>
<td class="label" valign="top">
<input type="password"
autocomplete="off"
id="db_pass_root"
name="db_pass_root"
class="needroot"
value="<?php
// We don't want to set password. It will be extracted from the forced install file at step1.
$autofill = ((!empty($force_install_database_rootpass)) ? '' : $db_pass_root);
if (!empty($dolibarr_main_prod)) {
$autofill = '';
} // Do not autofill password if instance is a production instance
if (!empty($_SERVER["SERVER_NAME"]) && !in_array($_SERVER["SERVER_NAME"],
array('127.0.0.1', 'localhost'))
) {
$autofill = '';
} // Do not autofill password for remote access
print dol_escape_htmltag($autofill);
?>"
<?php if ($force_install_noedit == 2 && $force_install_databaserootpass !== null) {
print ' disabled';
} ?>
>
</td>
<td class="comment"><?php echo $langs->trans("KeepEmptyIfNoPassword"); ?>
</td>
</tr>
@ -529,7 +577,7 @@ jQuery(document).ready(function() {
jQuery("#db_create_user").click(function() {
init_needroot();
});
<?php if ($force_install_noedit && empty($force_install_databasepass)) { ?>
<?php if ($force_install_noedit == 2 && empty($force_install_databasepass)) { ?>
jQuery("#db_pass").focus();
<?php } ?>
});

View File

@ -1,9 +1,10 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -489,3 +490,92 @@ function dolibarr_install_syslog($message, $level=LOG_DEBUG)
dol_syslog($message,$level);
}
/**
* Automatically detect Dolibarr's main document root
*
* @return string
*/
function detect_dolibarr_main_document_root()
{
// If PHP is in CGI mode, SCRIPT_FILENAME is PHP's path.
// Since that's not what we want, we suggest $_SERVER["DOCUMENT_ROOT"]
if (preg_match('/php$/i', $_SERVER["SCRIPT_FILENAME"]) || preg_match('/[\\/]php$/i',
$_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i', $_SERVER["SCRIPT_FILENAME"])
) {
$dolibarr_main_document_root = $_SERVER["DOCUMENT_ROOT"];
if (!preg_match('/[\\/]dolibarr[\\/]htdocs$/i', $dolibarr_main_document_root)) {
$dolibarr_main_document_root .= "/dolibarr/htdocs";
}
} else {
// We assume /install to be under /htdocs, so we get the parent directory of the current directory
$dolibarr_main_document_root = dirname(dirname($_SERVER["SCRIPT_FILENAME"]));
}
return $dolibarr_main_document_root;
}
/**
* Automatically detect Dolibarr's main data root
*
* @param string $dolibarr_main_document_root Current main document root
* @return string
*/
function detect_dolibarr_main_data_root($dolibarr_main_document_root)
{
$dolibarr_main_data_root = preg_replace("/\/htdocs$/", "", $dolibarr_main_document_root);
$dolibarr_main_data_root .= "/documents";
return $dolibarr_main_data_root;
}
/**
* Automatically detect Dolibarr's main URL root
*
* @return string
*/
function detect_dolibarr_main_url_root()
{
// If defined (Ie: Apache with Linux)
if (isset($_SERVER["SCRIPT_URI"])) {
$dolibarr_main_url_root = $_SERVER["SCRIPT_URI"];
} // If defined (Ie: Apache with Caudium)
elseif (isset($_SERVER["SERVER_URL"]) && isset($_SERVER["DOCUMENT_URI"])) {
$dolibarr_main_url_root = $_SERVER["SERVER_URL"] . $_SERVER["DOCUMENT_URI"];
} // If SCRIPT_URI, SERVER_URL, DOCUMENT_URI not defined (Ie: Apache 2.0.44 for Windows)
else {
$proto = 'http';
if (!empty($_SERVER["HTTP_HOST"])) {
$serverport = $_SERVER["HTTP_HOST"];
} else {
$serverport = $_SERVER["SERVER_NAME"];
}
$dolibarr_main_url_root = $proto . "://" . $serverport . $_SERVER["SCRIPT_NAME"];
}
// Clean proposed URL
// We assume /install to be under /htdocs, so we get the parent path of the current URL
$dolibarr_main_url_root = dirname(dirname($dolibarr_main_url_root));
return $dolibarr_main_url_root;
}
/**
* Replaces automatic database login by actual value
*
* @param string $force_install_databaserootlogin Login
* @return string
*/
function parse_database_login($force_install_databaserootlogin)
{
return preg_replace('/__SUPERUSERLOGIN__/', 'root', $force_install_databaserootlogin);
}
/**
* Replaces automatic database password by actual value
*
* @param string $force_install_databaserootpass Password
* @return string
*/
function parse_database_pass($force_install_databaserootpass)
{
return preg_replace('/__SUPERUSERPASSWORD__/', '', $force_install_databaserootpass);
}

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -26,6 +27,8 @@ include_once 'inc.php';
include_once '../core/class/html.form.class.php';
include_once '../core/class/html.formadmin.class.php';
global $langs;
$err = 0;
// If the config file exists and is filled, we're not on first install so we skip the language selection page

View File

@ -0,0 +1,73 @@
<?php
/* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** @var bool Hide PHP informations */
$force_install_nophpinfo = true;
/** @var int 1 = Lock and hide environment variables, 2 = Lock all set variables */
$force_install_noedit = 2;
/** @var string Information message */
$force_install_message = 'Welcome to your Dolibarr install';
/** @var string Data root absolute path (documents folder) */
$force_install_main_data_root = null;
/** @var bool Force HTTPS */
$force_install_mainforcehttps = true;
/** @var string Database name */
$force_install_database = 'dolibarr';
/** @var string Database driver (mysql|mysqli|pgsql|mssql|sqlite|sqlite3) */
$force_install_type = 'mysqli';
/** @var string Database server host */
$force_install_dbserver = 'localhost';
/** @var int Database server port */
$force_install_port = 3306;
/** @var string Database tables prefix */
$force_install_prefix = 'llx_';
/** @var bool Force database creation */
$force_install_createdatabase = true;
/** @var string Database username */
$force_install_databaselogin = 'root';
/** @var string Database password */
$force_install_databasepass = '';
/** @var bool Force database user creation */
$force_install_createuser = false;
/** @var string Database root username */
$force_install_databaserootlogin = 'root';
/** @var string Database root password */
$force_install_databaserootpass = '';
/** @var string Dolibarr super-administrator username */
$force_install_dolibarrlogin = 'admin';
/** @var bool Force install locking */
$force_install_lockinstall = true;
/** @var string Enable module(s) (Comma separated class names list) */
$force_install_module = 'modSociete,modFournisseur,modFacture';

View File

@ -29,6 +29,9 @@ ALTER TABLE llx_societe ADD COLUMN fk_account integer;
ALTER TABLE llx_website ADD COLUMN virtualhost varchar(255) after fk_default_home;
ALTER TABLE llx_chargesociales ADD COLUMN fk_account integer after fk_type;
ALTER TABLE llx_chargesociales ADD COLUMN fk_mode_reglement integer after fk_account;
ALTER TABLE llx_ecm_files ADD COLUMN gen_or_uploaded varchar(12) after cover;
DROP TABLE llx_document_generator;

View File

@ -27,6 +27,8 @@ create table llx_chargesociales
date_creation datetime, -- date de creation
date_valid datetime, -- date de validation
fk_type integer NOT NULL,
fk_account integer, -- bank account
fk_mode_reglement integer, -- mode de reglement
amount real default 0 NOT NULL,
paye smallint default 0 NOT NULL,
periode date,

View File

@ -1,10 +1,10 @@
<?php
/* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
/* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -30,6 +30,8 @@ define('DONOTLOADCONF',1); // To avoid loading conf by file inc.php
include 'inc.php';
global $langs;
$action=GETPOST('action','alpha');
$setuplang=(GETPOST('selectlang','',3)?GETPOST('selectlang','',3):'auto');
$langs->setDefaultLang($setuplang);
@ -38,12 +40,15 @@ $langs->load("admin");
$langs->load("install");
$langs->load("errors");
// Recuparation des information de connexion
// Dolibarr pages directory
$main_dir = GETPOST('main_dir');
// Directory for generated documents (invoices, orders, ecm, etc...)
$main_data_dir = GETPOST('main_data_dir') ? GETPOST('main_data_dir') : $main_dir . '/documents';
// Dolibarr root URL
$main_url = GETPOST('main_url');
// Database login informations
$userroot=GETPOST('db_user_root');
$passroot=GETPOST('db_pass_root');
// Repertoire des pages dolibarr
$main_dir=GETPOST('main_dir');
$main_url=GETPOST('main_url');
// Database server
$db_type=GETPOST('db_type','alpha');
$db_host=GETPOST('db_host','alpha');
@ -52,8 +57,16 @@ $db_user=GETPOST('db_user','alpha');
$db_pass=GETPOST('db_pass');
$db_port=GETPOST('db_port','int');
$db_prefix=GETPOST('db_prefix','alpha');
$db_create_database = GETPOST('db_create_database');
$db_create_user = GETPOST('db_create_user');
// Force https
$main_force_https = ((GETPOST("main_force_https") && (GETPOST("main_force_https") == "on" || GETPOST("main_force_https") == 1)) ? '1' : '0');
// Use alternative directory
$main_use_alt_dir = ((GETPOST("main_use_alt_dir") && (GETPOST("main_use_alt_dir") == "on" || GETPOST("main_use_alt_dir") == 1)) ? '' : '//');
// Alternative root directory name
$main_alt_dir_name = ((GETPOST("main_alt_dir_name") && GETPOST("main_alt_dir_name") != '') ? GETPOST("main_alt_dir_name") : 'custom');
session_start(); // To be able to keep info into session (used for not loosing pass during navigation. pass must not transit throug parmaeters)
session_start(); // To be able to keep info into session (used for not loosing pass during navigation. pass must not transit throug parameters)
// Save a flag to tell to restore input value if we do back
$_SESSION['dol_save_pass']=$db_pass;
@ -63,7 +76,58 @@ $_SESSION['dol_save_pass']=$db_pass;
$useforcedwizard=false;
$forcedfile="./install.forced.php";
if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php";
if (@file_exists($forcedfile)) { $useforcedwizard=true; include_once $forcedfile; }
if (@file_exists($forcedfile)) {
$useforcedwizard = true;
include_once $forcedfile;
// If forced install is enabled, let's replace post values. These are empty because form fields are disabled.
if ($force_install_noedit) {
$main_dir = detect_dolibarr_main_document_root();
if (!empty($force_install_main_data_root)) {
$main_data_dir = $force_install_main_data_root;
} else {
$main_data_dir = detect_dolibarr_main_data_root($main_dir);
}
$main_url = detect_dolibarr_main_url_root();
if (!empty($force_install_databaserootlogin)) {
$userroot = parse_database_login($force_install_databaserootlogin);
}
if (!empty($force_install_databaserootpass)) {
$passroot = parse_database_pass($force_install_databaserootpass);
}
}
if ($force_install_noedit == 2) {
if (!empty($force_install_type)) {
$db_type = $force_install_type;
}
if (!empty($force_install_dbserver)) {
$db_host = $force_install_dbserver;
}
if (!empty($force_install_database)) {
$db_name = $force_install_database;
}
if (!empty($force_install_databaselogin)) {
$db_user = $force_install_databaselogin;
}
if (!empty($force_install_databasepass)) {
$db_pass = $force_install_databasepass;
}
if (!empty($force_install_port)) {
$db_port = $force_install_port;
}
if (!empty($force_install_prefix)) {
$db_prefix = $force_install_prefix;
}
if (!empty($force_install_createdatabase)) {
$db_create_database = $force_install_createdatabase;
}
if (!empty($force_install_createuser)) {
$db_create_user = $force_install_createuser;
}
if (!empty($force_install_mainforcehttps)) {
$main_force_https = $force_install_mainforcehttps;
}
}
}
dolibarr_install_syslog("--- step1: entering step1.php page");
@ -134,28 +198,20 @@ if (! empty($main_url) && substr($main_url, dol_strlen($main_url) -1) == "/")
$main_url = substr($main_url, 0, dol_strlen($main_url)-1);
}
// Directory for generated documents (invoices, orders, ecm, etc...)
$main_data_dir=isset($_POST["main_data_dir"])?$_POST["main_data_dir"]:'';
if (! $main_data_dir) { $main_data_dir="$main_dir/documents"; }
// Test database connexion
if (! $error)
{
// Test database connection
if (! $error) {
$result=@include_once $main_dir."/core/db/".$db_type.'.class.php';
if ($result)
{
// If we ask database or user creation we need to connect as root, so we need root login
if (! empty($_POST["db_create_database"]) && ! $userroot)
{
if (!empty($db_create_database) && !$userroot) {
print '<div class="error">'.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$db_name).'</div>';
print '<br>';
print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
print $langs->trans("ErrorGoBackAndCorrectParameters");
$error++;
}
if (! empty($_POST["db_create_user"]) && ! $userroot)
{
if (!empty($db_create_user) && !$userroot) {
print '<div class="error">'.$langs->trans("YouAskLoginCreationSoDolibarrNeedToConnect",$db_user).'</div>';
print '<br>';
print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
@ -164,11 +220,9 @@ if (! $error)
}
// If we need root access
if (! $error && (! empty($_POST["db_create_database"]) || ! empty($_POST["db_create_user"])))
{
if (!$error && (!empty($db_create_database) || !empty($db_create_user))) {
$databasefortest=$db_name;
if (! empty($_POST["db_create_database"]))
{
if (!empty($db_create_database)) {
if ($db_type == 'mysql' || $db_type == 'mysqli')
{
$databasefortest='mysql';
@ -189,16 +243,13 @@ if (! $error)
dol_syslog("databasefortest=" . $databasefortest . " connected=" . $db->connected . " database_selected=" . $db->database_selected, LOG_DEBUG);
//print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected;
if (empty($_POST["db_create_database"]) && $db->connected && ! $db->database_selected)
{
if (empty($db_create_database) && $db->connected && !$db->database_selected) {
print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound",$db_name).'</div>';
print '<br>';
if (! $db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>';
print $langs->trans("ErrorGoBackAndCorrectParameters");
$error++;
}
elseif ($db->error && ! (! empty($_POST["db_create_database"]) && $db->connected))
{
} elseif ($db->error && (empty($db_create_database) && $db->connected)) {
// Note: you may experience error here with message "No such file or directory" when mysql was installed for the first time but not yet launched.
if ($db->error == "No such file or directory") print '<div class="error">'.$langs->trans("ErrorToConnectToMysqlCheckInstance").'</div>';
else print '<div class="error">'.$db->error.'</div>';
@ -210,8 +261,7 @@ if (! $error)
}
}
// If we need simple access
if (! $error && (empty($_POST["db_create_database"]) && empty($_POST["db_create_user"])))
{
if (!$error && (empty($db_create_database) && empty($db_create_user))) {
$db=getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, $db_port);
if ($db->error)
@ -246,8 +296,7 @@ else
if (! $error && $db->connected)
{
if (! empty($_POST["db_create_database"]))
{
if (! empty($db_create_database)) {
$result=$db->select_db($db_name);
if ($result)
{
@ -262,8 +311,7 @@ if (! $error && $db->connected)
// Define $defaultCharacterSet and $defaultDBSortingCollation
if (! $error && $db->connected)
{
if (! empty($_POST["db_create_database"])) // If we create database, we force default value
{
if (!empty($db_create_database)) { // If we create database, we force default value
$defaultCharacterSet=$db->forcecharset;
$defaultDBSortingCollation=$db->forcecollate;
}
@ -430,15 +478,6 @@ if (! $error && $db->connected && $action == "set")
// Table prefix
$main_db_prefix = (! empty($db_prefix) ? $db_prefix : 'llx_');
// Force https
$main_force_https = ((GETPOST("main_force_https") && (GETPOST("main_force_https") == "on" || GETPOST("main_force_https") == '1')) ? '1' : '0');
// Use alternative directory
$main_use_alt_dir = ((GETPOST("main_use_alt_dir") && (GETPOST("main_use_alt_dir") == "off" || GETPOST("main_use_alt_dir") == '0')) ? '//' : '');
// Alternative root directory name
$main_alt_dir_name = ((GETPOST("main_alt_dir_name") && GETPOST("main_alt_dir_name") != '') ? GETPOST("main_alt_dir_name") : 'custom');
// Write conf file on disk
if (! $error)
{
@ -469,14 +508,8 @@ if (! $error && $db->connected && $action == "set")
print '</td>';
print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
$userroot=isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
$passroot=isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
// Si creation utilisateur admin demandee, on le cree
if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on")
{
if (isset($db_create_user) && $db_create_user == "on") {
dolibarr_install_syslog("step1: create database user: " . $dolibarr_main_db_user);
//print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->port;
@ -569,8 +602,7 @@ if (! $error && $db->connected && $action == "set")
// If database creation is asked, we create it
if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_database"] == "on"))
{
if (!$error && (isset($db_create_database) && $db_create_database == "on")) {
dolibarr_install_syslog("step1: create database: " . $dolibarr_main_db_name . " " . $dolibarr_main_db_character_set . " " . $dolibarr_main_db_collation . " " . $dolibarr_main_db_user);
$newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port);
//print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit;
@ -873,7 +905,7 @@ function write_conf_file($conffile)
fputs($fp, '$dolibarr_main_restrict_os_commands=\'mysqldump, mysql, pg_dump, pgrestore\';');
fputs($fp,"\n");
fputs($fp, '$dolibarr_nocsrfcheck=\'0\';');
fputs($fp,"\n");

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,6 +28,8 @@ include 'inc.php';
require_once $dolibarr_main_document_root.'/core/class/conf.class.php';
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
global $langs;
$step = 2;
$ok = 0;
@ -61,7 +63,10 @@ if ($dolibarr_main_db_type == "sqlite3") $choix=5;
$useforcedwizard=false;
$forcedfile="./install.forced.php";
if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php";
if (@file_exists($forcedfile)) { $useforcedwizard=true; include_once $forcedfile; }
if (@file_exists($forcedfile)) {
$useforcedwizard = true;
include_once $forcedfile;
}
dolibarr_install_syslog("--- step2: entering step2.php page");

View File

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -30,6 +30,7 @@ include_once 'inc.php';
require_once $dolibarr_main_document_root.'/core/class/conf.class.php';
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
global $langs;
$setuplang=(GETPOST('selectlang','',3)?GETPOST('selectlang','',3):'auto');
$langs->setDefaultLang($setuplang);
@ -41,7 +42,10 @@ $langs->load("install");
$useforcedwizard=false;
$forcedfile="./install.forced.php";
if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php";
if (@file_exists($forcedfile)) { $useforcedwizard=true; include_once $forcedfile; }
if (@file_exists($forcedfile)) {
$useforcedwizard = true;
include_once $forcedfile;
}
dolibarr_install_syslog("--- step4: entering step4.php page");
@ -75,7 +79,7 @@ $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db-
if ($db->ok)
{
print '<tr><td>'.$langs->trans("DolibarrAdminLogin").' :</td><td>';
print '<input name="login" type="text" value="'.(! empty($_GET["login"])?$_GET["login"]:(isset($force_install_dolibarrlogin)?$force_install_dolibarrlogin:'')).'"></td></tr>';
print '<input name="login" type="text" value="' . (!empty($_GET["login"]) ? $_GET["login"] : (isset($force_install_dolibarrlogin) ? $force_install_dolibarrlogin : '')) . '"' . ($force_install_noedit == 2 && $force_install_dolibarrlogin !== null ? ' disabled' : '') . '></td></tr>';
print '<tr><td>'.$langs->trans("Password").' :</td><td>';
print '<input type="password" name="pass"></td></tr>';
print '<tr><td>'.$langs->trans("PasswordAgain").' :</td><td>';

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -31,6 +31,7 @@ if (file_exists($conffile)) include_once $conffile;
require_once $dolibarr_main_document_root . '/core/lib/admin.lib.php';
require_once $dolibarr_main_document_root . '/core/lib/security.lib.php'; // for dol_hash
global $langs;
$setuplang=GETPOST("selectlang",'',3)?GETPOST("selectlang",'',3):'auto';
$langs->setDefaultLang($setuplang);
@ -50,24 +51,25 @@ if (! empty($action) && preg_match('/upgrade/i', $action)) // If it's an old upg
$langs->load("admin");
$langs->load("install");
$login = GETPOST('login', 'alpha');
$pass = GETPOST('pass', 'alpha');
$pass_verif = GETPOST('pass_verif', 'alpha');
$success=0;
// Init "forced values" to nothing. "forced values" are used after using an install wizard (using a file install.forced.php).
if (! isset($force_install_type)) $force_install_type='';
if (! isset($force_install_dbserver)) $force_install_dbserver='';
if (! isset($force_install_port)) $force_install_port='';
if (! isset($force_install_database)) $force_install_database='';
if (! isset($force_install_createdatabase)) $force_install_createdatabase='';
if (! isset($force_install_databaselogin)) $force_install_databaselogin='';
if (! isset($force_install_databasepass)) $force_install_databasepass='';
if (! isset($force_install_databaserootlogin)) $force_install_databaserootlogin='';
if (! isset($force_install_databaserootpass)) $force_install_databaserootpass='';
if (! isset($force_install_lockinstall)) $force_install_lockinstall='';
// Now we load forced value from install.forced.php file.
$useforcedwizard=false;
$forcedfile="./install.forced.php";
if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php";
if (@file_exists($forcedfile)) { $useforcedwizard=true; include_once $forcedfile; }
if (@file_exists($forcedfile)) {
$useforcedwizard = true;
include_once $forcedfile;
// If forced install is enabled, let's replace post values. These are empty because form fields are disabled.
if ($force_install_noedit == 2) {
if (!empty($force_install_dolibarrlogin)) {
$login = $force_install_dolibarrlogin;
}
}
}
dolibarr_install_syslog("--- step5: entering step5.php page");
@ -77,25 +79,21 @@ dolibarr_install_syslog("--- step5: entering step5.php page");
*/
// If install, check pass and pass_verif used to create admin account
if ($action == "set")
{
if ($_POST["pass"] <> $_POST["pass_verif"])
{
header("Location: step4.php?error=1&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
exit;
}
if ($action == "set") {
if ($pass <> $pass_verif) {
header("Location: step4.php?error=1&selectlang=$setuplang" . (isset($login) ? '&login=' . $login : ''));
exit;
}
if (dol_strlen(trim($_POST["pass"])) == 0)
{
header("Location: step4.php?error=2&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
exit;
}
if (dol_strlen(trim($pass)) == 0) {
header("Location: step4.php?error=2&selectlang=$setuplang" . (isset($login) ? '&login=' . $login : ''));
exit;
}
if (dol_strlen(trim($_POST["login"])) == 0)
{
header("Location: step4.php?error=3&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
exit;
}
if (dol_strlen(trim($login)) == 0) {
header("Location: step4.php?error=3&selectlang=$setuplang" . (isset($login) ? '&login=' . $login : ''));
exit;
}
}
@ -187,8 +185,8 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action))
$newuser = new User($db);
$newuser->lastname='SuperAdmin';
$newuser->firstname='';
$newuser->login=$_POST["login"];
$newuser->pass=$_POST["pass"];
$newuser->login = $login;
$newuser->pass = $pass;
$newuser->admin=1;
$newuser->entity=0;
@ -196,7 +194,7 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action))
$result=$newuser->create($createuser,1);
if ($result > 0)
{
print $langs->trans("AdminLoginCreatedSuccessfuly",$_POST["login"])."<br>";
print $langs->trans("AdminLoginCreatedSuccessfuly", $login) . "<br>";
$success = 1;
}
else
@ -204,7 +202,7 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action))
if ($newuser->error == 'ErrorLoginAlreadyExists')
{
dolibarr_install_syslog('step5: AdminLoginAlreadyExists', LOG_WARNING);
print '<br><div class="warning">'.$langs->trans("AdminLoginAlreadyExists",$_POST["login"])."</div><br>";
print '<br><div class="warning">' . $langs->trans("AdminLoginAlreadyExists", $login) . "</div><br>";
$success = 1;
}
else
@ -320,8 +318,7 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action))
// Create lock file
// If first install
if ($action == "set")
{
if ($action == "set" && $success) {
if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
{
// Install is finished
@ -352,7 +349,7 @@ if ($action == "set")
print $langs->trans("YouNeedToPersonalizeSetup")."<br><br>";
print '<div class="center"><a href="../admin/index.php?mainmenu=home&leftmenu=setup'.(isset($_POST["login"])?'&username='.urlencode($_POST["login"]):'').'">';
print '<div class="center"><a href="../admin/index.php?mainmenu=home&leftmenu=setup' . (isset($login) ? '&username=' . urlencode($login) : '') . '">';
print $langs->trans("GoToSetupArea");
print '</a></div>';
}
@ -400,7 +397,7 @@ elseif (empty($action) || preg_match('/upgrade/i',$action))
print "<br>";
print '<div class="center"><a href="../index.php?mainmenu=home'.(isset($_POST["login"])?'&username='.urlencode($_POST["login"]):'').'">';
print '<div class="center"><a href="../index.php?mainmenu=home' . (isset($login) ? '&username=' . urlencode($login) : '') . '">';
print $langs->trans("GoToDolibarr");
print '</a></div>';
}

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -41,6 +41,8 @@ if (! file_exists($conffile))
require_once $conffile; if (! isset($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
global $langs;
$grant_query='';
$step = 2;
$ok = 0;

View File

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
/* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -47,6 +47,8 @@ require_once $dolibarr_main_document_root . '/core/lib/price.lib.php';
require_once $dolibarr_main_document_root . '/core/class/menubase.class.php';
require_once $dolibarr_main_document_root . '/core/lib/files.lib.php';
global $langs;
$grant_query='';
$step = 2;
$error = 0;

View File

@ -85,7 +85,8 @@ WithNoSlashAtTheEnd=Without the slash "/" at the end
DirectoryRecommendation=It is recommanded to use a directory outside of your directory of your web pages.
LoginAlreadyExists=Already exists
DolibarrAdminLogin=Dolibarr admin login
AdminLoginAlreadyExists=Dolibarr administrator account '<b>%s</b>' already exists. Go back, if you want to create another one.
AdminLoginAlreadyExists=Dolibarr administrator account '<b>%s</b>' already exists. Go back, if you want to create another one.
FailedToCreateAdminLogin=Failed to create Dolibarr administrator account.
WarningRemoveInstallDir=Warning, for security reasons, once the install or upgrade is complete, to avoid using install tools again, you should add a file called <b>install.lock</b> into Dolibarr document directory, in order to avoid malicious use of it.
FunctionNotAvailableInThisPHP=Not available on this PHP
ChoosedMigrateScript=Choose migration script

View File

@ -3132,7 +3132,7 @@ class Product extends CommonObject
*/
function getNomUrl($withpicto=0,$option='',$maxlength=0)
{
global $conf, $langs;
global $conf, $langs, $hookmanager;
include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
$result='';
@ -3157,6 +3157,17 @@ class Product extends CommonObject
$linkclose = '" title="'.str_replace('\n', '', dol_escape_htmltag($label, 1)).'" class="classfortooltip">';
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('productdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
if ($option == 'supplier') {
$link = '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$this->id.$linkclose;
$linkend='</a>';
@ -3174,8 +3185,8 @@ class Product extends CommonObject
}
if ($withpicto) {
if ($this->type == Product::TYPE_PRODUCT) $result.=($link.img_object($langs->trans("ShowProduct").' '.$this->label, 'product', 'class="classfortooltip"').$linkend.' ');
if ($this->type == Product::TYPE_SERVICE) $result.=($link.img_object($langs->trans("ShowService").' '.$this->label, 'service', 'class="classfortooltip"').$linkend.' ');
if ($this->type == Product::TYPE_PRODUCT) $result.=($link.img_object('', 'product', '').$linkend.' ');
if ($this->type == Product::TYPE_SERVICE) $result.=($link.img_object('', 'service', '').$linkend.' ');
}
$result.=$link.$newref.$linkend;
return $result;

View File

@ -108,7 +108,9 @@ class Entrepot extends CommonObject
function create($user)
{
global $conf;
$this->libelle = trim($this->libelle);
// Si libelle non defini, erreur
if ($this->libelle == '')
{

View File

@ -1811,7 +1811,7 @@ class Societe extends CommonObject
*/
function getNomUrl($withpicto=0, $option='', $maxlen=0, $notooltip=0)
{
global $conf,$langs;
global $conf,$langs, $hookmanager;
$name=$this->name?$this->name:$this->nom;
@ -1899,17 +1899,29 @@ class Societe extends CommonObject
// Add type of canvas
$link.=(!empty($this->canvas)?'&canvas='.$this->canvas:'').'"';
$linkclose='';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowCompany");
$link.=' alt="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$link.= ' title="'.dol_escape_htmltag($label, 1).'"';
$link.=' class="classfortooltip"';
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip"';
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('societedao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
}
$link.='>';
$link.=$linkclose.'>';
$linkend='</a>';
if ($withpicto) $result.=($link.img_object(($notooltip?'':$label), 'company', ($notooltip?'':'class="classfortooltip"')).$linkend);

View File

@ -1941,89 +1941,100 @@ class User extends CommonObject
*/
function getNomUrl($withpictoimg=0, $option='', $infologin=0, $notooltip=0, $maxlen=24, $hidethirdpartylogo=0, $mode='',$morecss='')
{
global $langs, $conf, $db;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
global $langs, $conf, $db, $hookmanager;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0;
$result = '';
$companylink = '';
$link = '';
$result = '';
$companylink = '';
$link = '';
$label = '<u>' . $langs->trans("User") . '</u>';
$label.= '<div width="100%">';
$label.= '<b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs,'','');
if (! empty($this->login))
$label.= '<br><b>' . $langs->trans('Login') . ':</b> ' . $this->login;
$label.= '<br><b>' . $langs->trans("EMail").':</b> '.$this->email;
if (! empty($this->admin))
$label.= '<br><b>' . $langs->trans("Administrator").'</b>: '.yn($this->admin);
if (! empty($this->societe_id) ) // Add thirdparty for external users
{
$thirdpartystatic = new Societe($db);
$thirdpartystatic->fetch($this->societe_id);
if (empty($hidethirdpartylogo)) $companylink = ' '.$thirdpartystatic->getNomUrl(2); // picto only of company
$company=' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')';
}
$type=($this->societe_id?$langs->trans("External").$company:$langs->trans("Internal"));
$label.= '<br><b>' . $langs->trans("Type") . ':</b> ' . $type;
$label.='</div>';
if (! empty($this->photo))
{
$label.= '<div class="photointooltip">';
$label.= Form::showphoto('userphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1);
$label.= '</div><div style="clear: both;"></div>';
}
$label = '<u>' . $langs->trans("User") . '</u>';
$label.= '<div width="100%">';
$label.= '<b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs,'','');
if (! empty($this->login))
$label.= '<br><b>' . $langs->trans('Login') . ':</b> ' . $this->login;
$label.= '<br><b>' . $langs->trans("EMail").':</b> '.$this->email;
if (! empty($this->admin))
$label.= '<br><b>' . $langs->trans("Administrator").'</b>: '.yn($this->admin);
if (! empty($this->societe_id) ) // Add thirdparty for external users
{
$thirdpartystatic = new Societe($db);
$thirdpartystatic->fetch($this->societe_id);
if (empty($hidethirdpartylogo)) $companylink = ' '.$thirdpartystatic->getNomUrl(2); // picto only of company
$company=' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')';
}
$type=($this->societe_id?$langs->trans("External").$company:$langs->trans("Internal"));
$label.= '<br><b>' . $langs->trans("Type") . ':</b> ' . $type;
$label.='</div>';
if (! empty($this->photo))
{
$label.= '<div class="photointooltip">';
$label.= Form::showphoto('userphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1);
$label.= '</div><div style="clear: both;"></div>';
}
// Info Login
if ($infologin)
{
$label.= '<br>';
$label.= '<br><u>'.$langs->trans("Connection").'</u>';
$label.= '<br><b>'.$langs->trans("IPAddress").'</b>: '.$_SERVER["REMOTE_ADDR"];
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $label.= '<br><b>'.$langs->trans("ConnectedOnMultiCompany").':</b> '.$conf->entity.' (user entity '.$this->entity.')';
$label.= '<br><b>'.$langs->trans("AuthenticationMode").':</b> '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo)?'':' (demo)');
$label.= '<br><b>'.$langs->trans("ConnectedSince").':</b> '.dol_print_date($this->datelastlogin,"dayhour");
$label.= '<br><b>'.$langs->trans("PreviousConnexion").':</b> '.dol_print_date($this->datepreviouslogin,"dayhour");
$label.= '<br><b>'.$langs->trans("CurrentTheme").':</b> '.$conf->theme;
$label.= '<br><b>'.$langs->trans("CurrentMenuManager").':</b> '.$menumanager->name;
$s=picto_from_langcode($langs->getDefaultLang());
$label.= '<br><b>'.$langs->trans("CurrentUserLanguage").':</b> '.($s?$s.' ':'').$langs->getDefaultLang();
$label.= '<br><b>'.$langs->trans("Browser").':</b> '.$conf->browser->name.($conf->browser->version?' '.$conf->browser->version:'').' ('.$_SERVER['HTTP_USER_AGENT'].')';
$label.= '<br><b>'.$langs->trans("Layout").':</b> '.$conf->browser->layout;
$label.= '<br><b>'.$langs->trans("Screen").':</b> '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight'];
if (! empty($conf->browser->phone)) $label.= '<br><b>'.$langs->trans("Phone").':</b> '.$conf->browser->phone;
if (! empty($_SESSION["disablemodules"])) $label.= '<br><b>'.$langs->trans("DisabledModules").':</b> <br>'.join(', ',explode(',',$_SESSION["disablemodules"]));
}
// Info Login
if ($infologin)
{
$label.= '<br>';
$label.= '<br><u>'.$langs->trans("Connection").'</u>';
$label.= '<br><b>'.$langs->trans("IPAddress").'</b>: '.$_SERVER["REMOTE_ADDR"];
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $label.= '<br><b>'.$langs->trans("ConnectedOnMultiCompany").':</b> '.$conf->entity.' (user entity '.$this->entity.')';
$label.= '<br><b>'.$langs->trans("AuthenticationMode").':</b> '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo)?'':' (demo)');
$label.= '<br><b>'.$langs->trans("ConnectedSince").':</b> '.dol_print_date($this->datelastlogin,"dayhour");
$label.= '<br><b>'.$langs->trans("PreviousConnexion").':</b> '.dol_print_date($this->datepreviouslogin,"dayhour");
$label.= '<br><b>'.$langs->trans("CurrentTheme").':</b> '.$conf->theme;
$label.= '<br><b>'.$langs->trans("CurrentMenuManager").':</b> '.$menumanager->name;
$s=picto_from_langcode($langs->getDefaultLang());
$label.= '<br><b>'.$langs->trans("CurrentUserLanguage").':</b> '.($s?$s.' ':'').$langs->getDefaultLang();
$label.= '<br><b>'.$langs->trans("Browser").':</b> '.$conf->browser->name.($conf->browser->version?' '.$conf->browser->version:'').' ('.$_SERVER['HTTP_USER_AGENT'].')';
$label.= '<br><b>'.$langs->trans("Layout").':</b> '.$conf->browser->layout;
$label.= '<br><b>'.$langs->trans("Screen").':</b> '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight'];
if (! empty($conf->browser->phone)) $label.= '<br><b>'.$langs->trans("Phone").':</b> '.$conf->browser->phone;
if (! empty($_SESSION["disablemodules"])) $label.= '<br><b>'.$langs->trans("DisabledModules").':</b> <br>'.join(', ',explode(',',$_SESSION["disablemodules"]));
}
if ($option == 'leave') $link.= '<a href="'.DOL_URL_ROOT.'/holiday/list.php?id='.$this->id.'"';
else $link.= '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'"';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$langs->load("users");
$label=$langs->trans("ShowUser");
$link.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$link.= ' title="'.dol_escape_htmltag($label, 1).'"';
$link.= ' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
}
$link.= '>';
if ($option == 'leave') $link.= '<a href="'.DOL_URL_ROOT.'/holiday/list.php?id='.$this->id.'"';
else $link.= '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'"';
$linkclose="";
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$langs->load("users");
$label=$langs->trans("ShowUser");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.= ' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
}
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('userdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
$link.=$linkclose.'>';
$linkend='</a>';
//if ($withpictoimg == -1) $result.='<div class="nowrap">';
//if ($withpictoimg == -1) $result.='<div class="nowrap">';
$result.=$link;
if ($withpictoimg)
{
$paddafterimage='';
if (abs($withpictoimg) == 1) $paddafterimage='style="padding-right: 3px;"';
if ($withpictoimg > 0) $picto='<div class="inline-block valignmiddle'.($morecss?' userimg'.$morecss:'').'">'.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"')).'</div>';
else $picto='<div class="inline-block valignmiddle'.($morecss?' userimg'.$morecss:'').'"'.($paddafterimage?' '.$paddafterimage:'').'>'.Form::showphoto('userphoto', $this, 0, 0, 0, 'loginphoto', 'mini', 0, 1).'</div>';
$result.=$picto;
if ($withpictoimg)
{
$paddafterimage='';
if (abs($withpictoimg) == 1) $paddafterimage='style="padding-right: 3px;"';
if ($withpictoimg > 0) $picto='<div class="inline-block valignmiddle'.($morecss?' userimg'.$morecss:'').'">'.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"')).'</div>';
else $picto='<div class="inline-block valignmiddle'.($morecss?' userimg'.$morecss:'').'"'.($paddafterimage?' '.$paddafterimage:'').'>'.Form::showphoto('userphoto', $this, 0, 0, 0, 'loginphoto', 'mini', 0, 1).'</div>';
$result.=$picto;
}
if (abs($withpictoimg) != 2)
{