forked from Wavyzz/dolibarr
Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -636,19 +636,20 @@ if ($action == 'addline' && $user->rights->commande->creer)
|
||||
);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','int')) $newlang=GETPOST('lang_id','int');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
|
||||
$ret=$object->fetch($id); // Reload to get new records
|
||||
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ if((isset($_GET['field']) && ! empty($_GET['field']))
|
||||
$type = GETPOST('type');
|
||||
$loadmethod = (GETPOST('loadmethod') ? GETPOST('loadmethod') : 'getValueFrom');
|
||||
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$element,$regs))
|
||||
if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs))
|
||||
{
|
||||
$element = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
@@ -62,9 +62,17 @@ if((isset($_GET['field']) && ! empty($_GET['field']))
|
||||
|
||||
if ($element == 'propal') $element = 'propale';
|
||||
else if ($element == 'fichinter') $element = 'ficheinter';
|
||||
else if ($element == 'order_supplier') {
|
||||
$element = 'fournisseur';
|
||||
$subelement = 'commande';
|
||||
}
|
||||
else if ($element == 'invoice_supplier') {
|
||||
$element = 'fournisseur';
|
||||
$subelement = 'facture';
|
||||
}
|
||||
|
||||
if ($user->rights->$element->lire || $user->rights->$element->read
|
||||
|| $user->rights->$element->$subelement->lire || $user->rights->$element->$subelement->read
|
||||
|| (isset($subelement) && ($user->rights->$element->$subelement->lire || $user->rights->$element->$subelement->read))
|
||||
|| ($element == 'payment' && $user->rights->facture->lire)
|
||||
|| ($element == 'payment_supplier' && $user->rights->fournisseur->facture->lire))
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
|
||||
$return=array();
|
||||
$error=0;
|
||||
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$element,$regs))
|
||||
if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs))
|
||||
{
|
||||
$element = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
@@ -69,9 +69,17 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
|
||||
|
||||
if ($element == 'propal') $element = 'propale';
|
||||
else if ($element == 'fichinter') $element = 'ficheinter';
|
||||
else if ($element == 'order_supplier') {
|
||||
$element = 'fournisseur';
|
||||
$subelement = 'commande';
|
||||
}
|
||||
else if ($element == 'invoice_supplier') {
|
||||
$element = 'fournisseur';
|
||||
$subelement = 'facture';
|
||||
}
|
||||
|
||||
if ($user->rights->$element->creer || $user->rights->$element->write
|
||||
|| $user->rights->$element->$subelement->creer || $user->rights->$element->$subelement->write
|
||||
|| (isset($subelement) && ($user->rights->$element->$subelement->creer || $user->rights->$element->$subelement->write))
|
||||
|| ($element == 'payment' && $user->rights->facture->paiement)
|
||||
|| ($element == 'payment_supplier' && $user->rights->fournisseur->facture->creer))
|
||||
{
|
||||
|
||||
@@ -631,6 +631,49 @@ class FormOther
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show form to select addresse
|
||||
*
|
||||
* @param int $page Page
|
||||
* @param string $selected Id condition pre-selectionne
|
||||
* @param string $htmlname Nom du formulaire select
|
||||
* @param string $origin Origine de l'appel pour pouvoir creer un retour
|
||||
* @param int $originid Id de l'origine
|
||||
* @return void
|
||||
*/
|
||||
function form_address($page, $selected='', $socid, $htmlname='address_id', $origin='', $originid='')
|
||||
{
|
||||
global $langs,$conf;
|
||||
if ($htmlname != "none")
|
||||
{
|
||||
print '<form method="post" action="'.$page.'">';
|
||||
print '<input type="hidden" name="action" value="setaddress">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||
print '<tr><td>';
|
||||
$this->select_address($selected, $socid, $htmlname, 1);
|
||||
print '</td>';
|
||||
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
$langs->load("companies");
|
||||
print ' <a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$socid.'&action=create&origin='.$origin.'&originid='.$originid.'>'.$langs->trans("AddAddress").'</a>';
|
||||
print '</td></tr></table></form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($selected)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT ."/societe/class/address.class.php");
|
||||
$address=new Address($this->db);
|
||||
$result=$address->fetch_address($selected);
|
||||
print '<a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$address->socid.'&id='.$address->id.'&action=edit&origin='.$origin.'&originid='.$originid.'>'.$address->label.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -644,6 +687,7 @@ class FormOther
|
||||
* @param int $selectedtask Id selected task
|
||||
* @param int $selectedproject Id selected project
|
||||
* @return void
|
||||
* TODO why this function is here ?
|
||||
*/
|
||||
function PLineSelect(&$inc, $parent, $lines, $level=0, $selectedtask=0, $selectedproject=0)
|
||||
{
|
||||
@@ -713,52 +757,6 @@ function PLineSelect(&$inc, $parent, $lines, $level=0, $selectedtask=0, $selecte
|
||||
$level--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show form to select addresse
|
||||
*
|
||||
* @param int $page Page
|
||||
* @param string $selected Id condition pre-selectionne
|
||||
* @param string $htmlname Nom du formulaire select
|
||||
* @param string $origin Origine de l'appel pour pouvoir creer un retour
|
||||
* @param int $originid Id de l'origine
|
||||
* @return void
|
||||
* @deprecated
|
||||
*/
|
||||
function form_address($page, $selected='', $socid, $htmlname='address_id', $origin='', $originid='')
|
||||
{
|
||||
global $langs,$conf;
|
||||
if ($htmlname != "none")
|
||||
{
|
||||
print '<form method="post" action="'.$page.'">';
|
||||
print '<input type="hidden" name="action" value="setaddress">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||
print '<tr><td>';
|
||||
$this->select_address($selected, $socid, $htmlname, 1);
|
||||
print '</td>';
|
||||
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
$langs->load("companies");
|
||||
print ' <a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$socid.'&action=create&origin='.$origin.'&originid='.$originid.'>'.$langs->trans("AddAddress").'</a>';
|
||||
print '</td></tr></table></form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($selected)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT ."/societe/class/address.class.php");
|
||||
$address=new Address($this->db);
|
||||
$result=$address->fetch_address($selected);
|
||||
print '<a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$address->socid.'&id='.$address->id.'&action=edit&origin='.$origin.'&originid='.$originid.'>'.$address->label.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -217,14 +217,19 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
|
||||
//print "xx".$tva_tx; exit;
|
||||
if ($result > 0)
|
||||
{
|
||||
$outputlangs = $langs;
|
||||
if (! empty($_REQUEST['lang_id']))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','int')) $newlang=GETPOST('lang_id','int');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$ret=$object->fetch($id); // Reload to get new records
|
||||
supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'));
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->facture->valider)
|
||||
elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->facture->valider)
|
||||
{
|
||||
$idwarehouse=GETPOST('idwarehouse');
|
||||
|
||||
@@ -111,7 +111,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseu
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->facture->supprimer)
|
||||
elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->facture->supprimer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->delete($id);
|
||||
@@ -126,7 +126,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisse
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
|
||||
elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$ret = $object->deleteline(GETPOST('lineid'));
|
||||
@@ -141,21 +141,21 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fourn
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
|
||||
elseif ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->set_paid($user);
|
||||
}
|
||||
|
||||
// Set supplier ref
|
||||
if (($action == 'setref_supplier' || $action == 'set_ref_supplier') && $user->rights->fournisseur->facture->creer)
|
||||
elseif (($action == 'setref_supplier' || $action == 'set_ref_supplier') && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->set_ref_supplier($user, $_POST['ref_supplier']);
|
||||
}
|
||||
|
||||
// Set label
|
||||
if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
|
||||
elseif ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->label=$_POST['label'];
|
||||
@@ -163,25 +163,25 @@ if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
|
||||
if ($result < 0) dol_print_error($db);
|
||||
}
|
||||
|
||||
if ($action == 'setdate' && $user->rights->fournisseur->facture->creer)
|
||||
elseif ($action == 'setdate' && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->date=dol_mktime(12,0,0,$_POST['datemonth'],$_POST['dateday'],$_POST['dateyear']);
|
||||
$object->date=dol_mktime(12,0,0,$_POST['datefmonth'],$_POST['datefday'],$_POST['datefyear']);
|
||||
if ($object->date_echeance < $object->date) $object->date_echeance=$object->date;
|
||||
$result=$object->update($user);
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
if ($action == 'setdate_echeance' && $user->rights->fournisseur->facture->creer)
|
||||
elseif ($action == 'setdate_echeance' && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->date_echeance=dol_mktime(12,0,0,$_POST['date_echeancemonth'],$_POST['date_echeanceday'],$_POST['date_echeanceyear']);
|
||||
$object->date_echeance=dol_mktime(12,0,0,$_POST['date_lim_reglementmonth'],$_POST['date_lim_reglementday'],$_POST['date_lim_reglementyear']);
|
||||
if ($object->date_echeance < $object->date) $object->date_echeance=$object->date;
|
||||
$result=$object->update($user);
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
|
||||
// Delete payment
|
||||
if($action == 'deletepaiement')
|
||||
elseif($action == 'deletepaiement')
|
||||
{
|
||||
$object->fetch($id);
|
||||
if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0)
|
||||
@@ -193,7 +193,7 @@ if($action == 'deletepaiement')
|
||||
}
|
||||
|
||||
// Create
|
||||
if ($action == 'add' && $user->rights->fournisseur->facture->creer)
|
||||
elseif ($action == 'add' && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$error=0;
|
||||
|
||||
@@ -379,7 +379,7 @@ if ($action == 'add' && $user->rights->fournisseur->facture->creer)
|
||||
}
|
||||
|
||||
// Modification d'une ligne
|
||||
if ($action == 'update_line')
|
||||
elseif ($action == 'update_line')
|
||||
{
|
||||
if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification
|
||||
{
|
||||
@@ -428,7 +428,7 @@ if ($action == 'update_line')
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'addline')
|
||||
elseif ($action == 'addline')
|
||||
{
|
||||
$ret=$object->fetch($id);
|
||||
if ($ret < 0)
|
||||
@@ -507,11 +507,15 @@ if ($action == 'addline')
|
||||
//print "xx".$tva_tx; exit;
|
||||
if ($result > 0)
|
||||
{
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
if (! empty($_REQUEST['lang_id']))
|
||||
$newlang='';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','int')) $newlang=GETPOST('lang_id','int');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
//if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs);
|
||||
|
||||
@@ -535,7 +539,7 @@ if ($action == 'addline')
|
||||
$action = '';
|
||||
}
|
||||
|
||||
if ($action == 'classin')
|
||||
elseif ($action == 'classin')
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->setProject($_POST['projectid']);
|
||||
@@ -543,7 +547,7 @@ if ($action == 'classin')
|
||||
|
||||
|
||||
// Set invoice to draft status
|
||||
if ($action == 'edit' && $user->rights->fournisseur->facture->creer)
|
||||
elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
|
||||
@@ -569,7 +573,7 @@ if ($action == 'edit' && $user->rights->fournisseur->facture->creer)
|
||||
}
|
||||
|
||||
// Set invoice to validated/unpaid status
|
||||
if ($action == 'reopen' && $user->rights->fournisseur->facture->creer)
|
||||
elseif ($action == 'reopen' && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$result = $object->fetch($id);
|
||||
if ($object->statut == 2
|
||||
@@ -774,7 +778,7 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
|
||||
}
|
||||
|
||||
// Build document
|
||||
if ($action == 'builddoc')
|
||||
elseif ($action == 'builddoc')
|
||||
{
|
||||
// Save modele used
|
||||
$object->fetch($id);
|
||||
@@ -803,7 +807,7 @@ if ($action == 'builddoc')
|
||||
}
|
||||
|
||||
// Delete file in doc form
|
||||
if ($action == 'remove_file')
|
||||
elseif ($action == 'remove_file')
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
||||
|
||||
@@ -1336,13 +1340,13 @@ else
|
||||
print '</tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$form->editfieldkey("Date",'date',$object->datep,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker').'</td><td colspan="3">';
|
||||
print $form->editfieldval("Date",'date',$object->datep,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker');
|
||||
print '<tr><td>'.$form->editfieldkey("Date",'datef',$object->datep,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker').'</td><td colspan="3">';
|
||||
print $form->editfieldval("Date",'datef',$object->datep,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker');
|
||||
print '</td>';
|
||||
|
||||
// Due date
|
||||
print '<tr><td>'.$form->editfieldkey("DateMaxPayment",'date_echeance',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker').'</td><td colspan="3">';
|
||||
print $form->editfieldval("DateMaxPayment",'date_echeance',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker');
|
||||
print '<tr><td>'.$form->editfieldkey("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker').'</td><td colspan="3">';
|
||||
print $form->editfieldval("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker');
|
||||
print '</td>';
|
||||
|
||||
// Status
|
||||
|
||||
Reference in New Issue
Block a user