Fix: add commonorder and commoninvoice classes
This commit is contained in:
parent
e18d3c6e18
commit
e1b0d183e4
@ -25,7 +25,7 @@
|
||||
* \ingroup commande
|
||||
* \brief Fichier des classes de commandes
|
||||
*/
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/core/class/commonorder.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||
* \class Commande
|
||||
* \brief Class to manage customers orders
|
||||
*/
|
||||
class Commande extends CommonObject
|
||||
class Commande extends CommonOrder
|
||||
{
|
||||
public $element='commande';
|
||||
public $table_element='commande';
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
* \brief File of class to manage invoices
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/core/class/commoninvoice.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT ."/product/class/product.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT ."/societe/class/client.class.php");
|
||||
|
||||
@ -37,7 +37,7 @@ require_once(DOL_DOCUMENT_ROOT ."/societe/class/client.class.php");
|
||||
/**
|
||||
* Class to manage invoices
|
||||
*/
|
||||
class Facture extends CommonObject
|
||||
class Facture extends CommonInvoice
|
||||
{
|
||||
public $element='facture';
|
||||
public $table_element='facture';
|
||||
@ -2261,41 +2261,6 @@ class Facture extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return amount of payments already done
|
||||
*
|
||||
* @return int Amount of payment already done, <0 if KO
|
||||
*/
|
||||
function getSommePaiement()
|
||||
{
|
||||
$table='paiement_facture';
|
||||
$field='fk_facture';
|
||||
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
|
||||
{
|
||||
$table='paiementfourn_facturefourn';
|
||||
$field='fk_facturefourn';
|
||||
}
|
||||
|
||||
$sql = 'SELECT sum(amount) as amount';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$table;
|
||||
$sql.= ' WHERE '.$field.' = '.$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::getSommePaiement sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$this->db->free($resql);
|
||||
return $obj->amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of payments
|
||||
*
|
||||
@ -2393,233 +2358,6 @@ class Facture extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie tableau des ids de facture avoir issus de la facture
|
||||
*
|
||||
* @return array Tableau d'id de factures avoirs
|
||||
*/
|
||||
function getListIdAvoirFromInvoice()
|
||||
{
|
||||
$idarray=array();
|
||||
|
||||
$sql = 'SELECT rowid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql.= ' WHERE fk_facture_source = '.$this->id;
|
||||
$sql.= ' AND type = 2';
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$idarray[]=$row[0];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
return $idarray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie l'id de la facture qui la remplace
|
||||
*
|
||||
* @param string $option filtre sur statut ('', 'validated', ...)
|
||||
* @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon
|
||||
*/
|
||||
function getIdReplacingInvoice($option='')
|
||||
{
|
||||
$sql = 'SELECT rowid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql.= ' WHERE fk_facture_source = '.$this->id;
|
||||
$sql.= ' AND type < 2';
|
||||
if ($option == 'validated') $sql.= ' AND fk_statut = 1';
|
||||
// PROTECTION BAD DATA
|
||||
// Au cas ou base corrompue et qu'il y a une facture de remplacement validee
|
||||
// et une autre non, on donne priorite a la validee.
|
||||
// Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes
|
||||
// ont cree en meme temps une facture de remplacement pour la meme facture)
|
||||
$sql.= ' ORDER BY fk_statut DESC';
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
// Si il y en a
|
||||
return $obj->rowid;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Si aucune facture ne remplace
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le libelle du type de facture
|
||||
*
|
||||
* @return string Libelle
|
||||
*/
|
||||
function getLibType()
|
||||
{
|
||||
global $langs;
|
||||
if ($this->type == 0) return $langs->trans("InvoiceStandard");
|
||||
if ($this->type == 1) return $langs->trans("InvoiceReplacement");
|
||||
if ($this->type == 2) return $langs->trans("InvoiceAvoir");
|
||||
if ($this->type == 3) return $langs->trans("InvoiceDeposit");
|
||||
if ($this->type == 4) return $langs->trans("InvoiceProForma");
|
||||
return $langs->trans("Unknown");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return label of object status
|
||||
*
|
||||
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto
|
||||
* @param int $alreadypaid 0=No payment already done, 1=Some payments already done
|
||||
* @return string Label
|
||||
*/
|
||||
function getLibStatut($mode=0,$alreadypaid=-1)
|
||||
{
|
||||
return $this->LibStatut($this->paye,$this->statut,$mode,$alreadypaid,$this->type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoi le libelle d'un statut donne
|
||||
*
|
||||
* @param int $paye Etat paye
|
||||
* @param int $statut Id statut
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @param double $alreadypaid Montant deja paye
|
||||
* @param int $type Type facture
|
||||
* @return string Libelle du statut
|
||||
*/
|
||||
function LibStatut($paye,$statut,$mode=0,$alreadypaid=-1,$type=0)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load('bills');
|
||||
|
||||
//print "$paye,$statut,$mode,$alreadypaid,$type";
|
||||
if ($mode == 0)
|
||||
{
|
||||
$prefix='';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
|
||||
if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid');
|
||||
return $langs->trans('Bill'.$prefix.'StatusStarted');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 2) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
|
||||
elseif ($type == 3) return $langs->trans('Bill'.$prefix.'StatusConverted');
|
||||
else return $langs->trans('Bill'.$prefix.'StatusPaid');
|
||||
}
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
$prefix='Short';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
|
||||
if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid');
|
||||
return $langs->trans('Bill'.$prefix.'StatusStarted');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 2) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
|
||||
elseif ($type == 3) return $langs->trans('Bill'.$prefix.'StatusConverted');
|
||||
else return $langs->trans('Bill'.$prefix.'StatusPaid');
|
||||
}
|
||||
}
|
||||
if ($mode == 2)
|
||||
{
|
||||
$prefix='Short';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
|
||||
if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid');
|
||||
return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 2) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
|
||||
elseif ($type == 3) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted');
|
||||
else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid');
|
||||
}
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
$prefix='Short';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7');
|
||||
if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1');
|
||||
return img_picto($langs->trans('BillStatusStarted'),'statut3');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 2) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
|
||||
elseif ($type == 3) return img_picto($langs->trans('BillStatusConverted'),'statut6');
|
||||
else return img_picto($langs->trans('BillStatusPaid'),'statut6');
|
||||
}
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
|
||||
if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid');
|
||||
return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 2) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted');
|
||||
elseif ($type == 3) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted');
|
||||
else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid');
|
||||
}
|
||||
}
|
||||
if ($mode == 5)
|
||||
{
|
||||
$prefix='Short';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return $langs->trans('Bill'.$prefix.'StatusDraft').' '.img_picto($langs->trans('BillStatusDraft'),'statut0');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('BillStatusCanceled'),'statut5');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7');
|
||||
if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid').' '.img_picto($langs->trans('BillStatusNotPaid'),'statut1');
|
||||
return $langs->trans('Bill'.$prefix.'StatusStarted').' '.img_picto($langs->trans('BillStatusStarted'),'statut3');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 2) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' '.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
|
||||
elseif ($type == 3) return $langs->trans('Bill'.$prefix.'StatusConverted').' '.img_picto($langs->trans('BillStatusConverted'),'statut6');
|
||||
else return $langs->trans('Bill'.$prefix.'StatusPaid').' '.img_picto($langs->trans('BillStatusPaid'),'statut6');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return next reference of invoice not already used (or last reference)
|
||||
* according to numbering module defined into constant FACTURE_ADDON
|
||||
|
||||
@ -78,8 +78,8 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
|
||||
$subelement = 'facture';
|
||||
}
|
||||
|
||||
if ($user->rights->$element->creer || $user->rights->$element->write
|
||||
|| (isset($subelement) && ($user->rights->$element->$subelement->creer || $user->rights->$element->$subelement->write))
|
||||
if (! empty($user->rights->$element->creer) || ! empty($user->rights->$element->write)
|
||||
|| (isset($subelement) && (! empty($user->rights->$element->$subelement->creer) || ! empty($user->rights->$element->$subelement->write)))
|
||||
|| ($element == 'payment' && $user->rights->facture->paiement)
|
||||
|| ($element == 'payment_supplier' && $user->rights->fournisseur->facture->creer))
|
||||
{
|
||||
@ -117,7 +117,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
|
||||
{
|
||||
$loadcache = $form->$loadcachename;
|
||||
$value = $loadcache[$newvalue];
|
||||
|
||||
|
||||
if (! empty($form->$loadviewname))
|
||||
{
|
||||
$loadview = $form->$loadviewname;
|
||||
@ -138,7 +138,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
|
||||
$module = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
}
|
||||
|
||||
|
||||
dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php');
|
||||
$classname = 'Actions'.ucfirst($subelement);
|
||||
$object = new $classname($db);
|
||||
@ -147,7 +147,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
|
||||
{
|
||||
$loadcache = $object->$loadcachename;
|
||||
$value = $loadcache[$newvalue];
|
||||
|
||||
|
||||
if (! empty($object->$loadviewname))
|
||||
{
|
||||
$loadview = $object->$loadviewname;
|
||||
@ -164,7 +164,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! is_object($object) || empty($savemethod)) $object = new GenericObject($db);
|
||||
if ((isset($object) && ! is_object($object)) || empty($savemethod)) $object = new GenericObject($db);
|
||||
|
||||
// Specific for add_object_linked()
|
||||
// TODO add a function for variable treatment
|
||||
@ -172,7 +172,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
|
||||
$object->ext_element = $ext_element;
|
||||
$object->fk_element = $fk_element;
|
||||
$object->element = $element;
|
||||
|
||||
|
||||
$ret=$object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format);
|
||||
if ($ret > 0)
|
||||
{
|
||||
|
||||
293
htdocs/core/class/commoninvoice.class.php
Normal file
293
htdocs/core/class/commoninvoice.class.php
Normal file
@ -0,0 +1,293 @@
|
||||
<?php
|
||||
/* Copyright (C) 2012 Regis Houssin <regis@dolibarr.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 2 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/class/commoninvoice.class.php
|
||||
* \ingroup core
|
||||
* \brief File of the superclass of invoices classes (customer and supplier)
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
||||
|
||||
/**
|
||||
* \class CommonInvoice
|
||||
* \brief Superclass for invoices classes
|
||||
*/
|
||||
abstract class CommonInvoice extends CommonObject
|
||||
{
|
||||
/**
|
||||
* Return amount of payments already done
|
||||
*
|
||||
* @return int Amount of payment already done, <0 if KO
|
||||
*/
|
||||
function getSommePaiement()
|
||||
{
|
||||
$table='paiement_facture';
|
||||
$field='fk_facture';
|
||||
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
|
||||
{
|
||||
$table='paiementfourn_facturefourn';
|
||||
$field='fk_facturefourn';
|
||||
}
|
||||
|
||||
$sql = 'SELECT sum(amount) as amount';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$table;
|
||||
$sql.= ' WHERE '.$field.' = '.$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::getSommePaiement sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$this->db->free($resql);
|
||||
return $obj->amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie tableau des ids de facture avoir issus de la facture
|
||||
*
|
||||
* @return array Tableau d'id de factures avoirs
|
||||
*/
|
||||
function getListIdAvoirFromInvoice()
|
||||
{
|
||||
$idarray=array();
|
||||
|
||||
$sql = 'SELECT rowid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql.= ' WHERE fk_facture_source = '.$this->id;
|
||||
$sql.= ' AND type = 2';
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$idarray[]=$row[0];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
return $idarray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie l'id de la facture qui la remplace
|
||||
*
|
||||
* @param string $option filtre sur statut ('', 'validated', ...)
|
||||
* @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon
|
||||
*/
|
||||
function getIdReplacingInvoice($option='')
|
||||
{
|
||||
$sql = 'SELECT rowid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql.= ' WHERE fk_facture_source = '.$this->id;
|
||||
$sql.= ' AND type < 2';
|
||||
if ($option == 'validated') $sql.= ' AND fk_statut = 1';
|
||||
// PROTECTION BAD DATA
|
||||
// Au cas ou base corrompue et qu'il y a une facture de remplacement validee
|
||||
// et une autre non, on donne priorite a la validee.
|
||||
// Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes
|
||||
// ont cree en meme temps une facture de remplacement pour la meme facture)
|
||||
$sql.= ' ORDER BY fk_statut DESC';
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
// Si il y en a
|
||||
return $obj->rowid;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Si aucune facture ne remplace
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le libelle du type de facture
|
||||
*
|
||||
* @return string Libelle
|
||||
*/
|
||||
function getLibType()
|
||||
{
|
||||
global $langs;
|
||||
if ($this->type == 0) return $langs->trans("InvoiceStandard");
|
||||
if ($this->type == 1) return $langs->trans("InvoiceReplacement");
|
||||
if ($this->type == 2) return $langs->trans("InvoiceAvoir");
|
||||
if ($this->type == 3) return $langs->trans("InvoiceDeposit");
|
||||
if ($this->type == 4) return $langs->trans("InvoiceProForma");
|
||||
return $langs->trans("Unknown");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return label of object status
|
||||
*
|
||||
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto
|
||||
* @param int $alreadypaid 0=No payment already done, 1=Some payments already done
|
||||
* @return string Label
|
||||
*/
|
||||
function getLibStatut($mode=0,$alreadypaid=-1)
|
||||
{
|
||||
return $this->LibStatut($this->paye,$this->statut,$mode,$alreadypaid,$this->type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoi le libelle d'un statut donne
|
||||
*
|
||||
* @param int $paye Etat paye
|
||||
* @param int $statut Id statut
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @param double $alreadypaid Montant deja paye
|
||||
* @param int $type Type facture
|
||||
* @return string Libelle du statut
|
||||
*/
|
||||
function LibStatut($paye,$statut,$mode=0,$alreadypaid=-1,$type=0)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load('bills');
|
||||
|
||||
//print "$paye,$statut,$mode,$alreadypaid,$type";
|
||||
if ($mode == 0)
|
||||
{
|
||||
$prefix='';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
|
||||
if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid');
|
||||
return $langs->trans('Bill'.$prefix.'StatusStarted');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 2) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
|
||||
elseif ($type == 3) return $langs->trans('Bill'.$prefix.'StatusConverted');
|
||||
else return $langs->trans('Bill'.$prefix.'StatusPaid');
|
||||
}
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
$prefix='Short';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
|
||||
if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid');
|
||||
return $langs->trans('Bill'.$prefix.'StatusStarted');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 2) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
|
||||
elseif ($type == 3) return $langs->trans('Bill'.$prefix.'StatusConverted');
|
||||
else return $langs->trans('Bill'.$prefix.'StatusPaid');
|
||||
}
|
||||
}
|
||||
if ($mode == 2)
|
||||
{
|
||||
$prefix='Short';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
|
||||
if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid');
|
||||
return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 2) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
|
||||
elseif ($type == 3) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted');
|
||||
else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid');
|
||||
}
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
$prefix='Short';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7');
|
||||
if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1');
|
||||
return img_picto($langs->trans('BillStatusStarted'),'statut3');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 2) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
|
||||
elseif ($type == 3) return img_picto($langs->trans('BillStatusConverted'),'statut6');
|
||||
else return img_picto($langs->trans('BillStatusPaid'),'statut6');
|
||||
}
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
|
||||
if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid');
|
||||
return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 2) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted');
|
||||
elseif ($type == 3) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted');
|
||||
else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid');
|
||||
}
|
||||
}
|
||||
if ($mode == 5)
|
||||
{
|
||||
$prefix='Short';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return $langs->trans('Bill'.$prefix.'StatusDraft').' '.img_picto($langs->trans('BillStatusDraft'),'statut0');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('BillStatusCanceled'),'statut5');
|
||||
if (($statut == 3 || $statut == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7');
|
||||
if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid').' '.img_picto($langs->trans('BillStatusNotPaid'),'statut1');
|
||||
return $langs->trans('Bill'.$prefix.'StatusStarted').' '.img_picto($langs->trans('BillStatusStarted'),'statut3');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 2) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' '.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
|
||||
elseif ($type == 3) return $langs->trans('Bill'.$prefix.'StatusConverted').' '.img_picto($langs->trans('BillStatusConverted'),'statut6');
|
||||
else return $langs->trans('Bill'.$prefix.'StatusPaid').' '.img_picto($langs->trans('BillStatusPaid'),'statut6');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1501,23 +1501,27 @@ abstract class CommonObject
|
||||
$this->total_ttc += $obj->total_ttc;
|
||||
|
||||
// Define vatrates with totals for each line and for all lines
|
||||
$vatrates[$this->vatrate][]=array(
|
||||
'total_ht' =>$obj->total_ht,
|
||||
'total_tva' =>$obj->total_tva,
|
||||
'total_ttc' =>$obj->total_ttc,
|
||||
'total_localtax1'=>$obj->total_localtax1,
|
||||
'total_localtax2'=>$obj->total_localtax2
|
||||
);
|
||||
if (! isset($vatrates_alllines[$this->vatrate]['total_ht'])) $vatrates_alllines[$this->vatrate]['total_ht']=0;
|
||||
if (! isset($vatrates_alllines[$this->vatrate]['total_tva'])) $vatrates_alllines[$this->vatrate]['total_tva']=0;
|
||||
if (! isset($vatrates_alllines[$this->vatrate]['total_localtax1'])) $vatrates_alllines[$this->vatrate]['total_localtax1']=0;
|
||||
if (! isset($vatrates_alllines[$this->vatrate]['total_localtax2'])) $vatrates_alllines[$this->vatrate]['total_localtax2']=0;
|
||||
if (! isset($vatrates_alllines[$this->vatrate]['total_ttc'])) $vatrates_alllines[$this->vatrate]['total_ttc']=0;
|
||||
$vatrates_alllines[$this->vatrate]['total_ht'] +=$obj->total_ht;
|
||||
$vatrates_alllines[$this->vatrate]['total_tva'] +=$obj->total_tva;
|
||||
$vatrates_alllines[$this->vatrate]['total_localtax1']+=$obj->total_localtax1;
|
||||
$vatrates_alllines[$this->vatrate]['total_localtax2']+=$obj->total_localtax2;
|
||||
$vatrates_alllines[$this->vatrate]['total_ttc'] +=$obj->total_ttc;
|
||||
// TODO $vatrates and $vatrates_alllines not used ?
|
||||
if (! empty($this->vatrate))
|
||||
{
|
||||
$vatrates[$this->vatrate][]=array(
|
||||
'total_ht' =>$obj->total_ht,
|
||||
'total_tva' =>$obj->total_tva,
|
||||
'total_ttc' =>$obj->total_ttc,
|
||||
'total_localtax1'=>$obj->total_localtax1,
|
||||
'total_localtax2'=>$obj->total_localtax2
|
||||
);
|
||||
if (! isset($vatrates_alllines[$this->vatrate]['total_ht'])) $vatrates_alllines[$this->vatrate]['total_ht']=0;
|
||||
if (! isset($vatrates_alllines[$this->vatrate]['total_tva'])) $vatrates_alllines[$this->vatrate]['total_tva']=0;
|
||||
if (! isset($vatrates_alllines[$this->vatrate]['total_localtax1'])) $vatrates_alllines[$this->vatrate]['total_localtax1']=0;
|
||||
if (! isset($vatrates_alllines[$this->vatrate]['total_localtax2'])) $vatrates_alllines[$this->vatrate]['total_localtax2']=0;
|
||||
if (! isset($vatrates_alllines[$this->vatrate]['total_ttc'])) $vatrates_alllines[$this->vatrate]['total_ttc']=0;
|
||||
$vatrates_alllines[$this->vatrate]['total_ht'] +=$obj->total_ht;
|
||||
$vatrates_alllines[$this->vatrate]['total_tva'] +=$obj->total_tva;
|
||||
$vatrates_alllines[$this->vatrate]['total_localtax1']+=$obj->total_localtax1;
|
||||
$vatrates_alllines[$this->vatrate]['total_localtax2']+=$obj->total_localtax2;
|
||||
$vatrates_alllines[$this->vatrate]['total_ttc'] +=$obj->total_ttc;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
35
htdocs/core/class/commonorder.class.php
Normal file
35
htdocs/core/class/commonorder.class.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/* Copyright (C) 2012 Regis Houssin <regis@dolibarr.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 2 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/class/commonorder.class.php
|
||||
* \ingroup core
|
||||
* \brief File of the superclass of orders classes (customer and supplier)
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
||||
|
||||
/**
|
||||
* \class CommonOrder
|
||||
* \brief Superclass for orders classes
|
||||
*/
|
||||
abstract class CommonOrder extends CommonObject
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -274,7 +274,8 @@ class Form
|
||||
else if (preg_match('/^datepicker/',$inputType))
|
||||
{
|
||||
$tmp=explode(':',$inputType);
|
||||
$inputType=$tmp[0]; $inputOption=$tmp[1];
|
||||
$inputType=$tmp[0];
|
||||
if (! empty($tmp[1])) $inputOption=$tmp[1];
|
||||
if (! empty($tmp[2])) $savemethod=$tmp[2];
|
||||
|
||||
$out.= '<input id="timestamp" type="hidden"/>'."\n"; // Use for timestamp format
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2006 Marc Barilley/Ocebo <marc@ocebo.com>
|
||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerker@telenet.be>
|
||||
@ -713,6 +713,7 @@ class FormOther
|
||||
$out.= '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '"'.$option.' >';
|
||||
if($useempty)
|
||||
{
|
||||
$selected_html='';
|
||||
if ($selected == '') $selected_html = ' selected="selected"';
|
||||
$out.= '<option value=""' . $selected_html . '> </option>';
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ function facturefourn_prepare_head($object)
|
||||
$head[$h][1] = $langs->trans('CardBill');
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id;
|
||||
@ -54,7 +54,7 @@ function facturefourn_prepare_head($object)
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice');
|
||||
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
|
||||
@ -98,7 +98,7 @@ function ordersupplier_prepare_head($object)
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
|
||||
if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
|
||||
{
|
||||
$langs->load("stocks");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id;
|
||||
@ -106,7 +106,7 @@ function ordersupplier_prepare_head($object)
|
||||
$head[$h][2] = 'dispatch';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
|
||||
@ -120,7 +120,7 @@ function ordersupplier_prepare_head($object)
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order');
|
||||
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
|
||||
|
||||
@ -2826,7 +2826,7 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod=0, $idpr
|
||||
if (!is_object($societe_vendeuse)) return -1;
|
||||
if (!is_object($societe_acheteuse)) return -1;
|
||||
|
||||
dol_syslog("get_default_tva: seller use vat=".$societe_vendeuse->tva_assuj.", seller country=".$societe_vendeuse->pays_code.", seller in cee=".$societe_vendeuse->isInEEC().", buyer country=".$societe_acheteuse->pays_code.", buyer in cee=".$societe_acheteuse->isInEEC().", idprod=".$idprod.", idprodfournprice=".$idprodfournprice.", SERVICE_ARE_ECOMMERCE_200238EC=".$conf->global->SERVICES_ARE_ECOMMERCE_200238EC);
|
||||
dol_syslog("get_default_tva: seller use vat=".$societe_vendeuse->tva_assuj.", seller country=".$societe_vendeuse->pays_code.", seller in cee=".$societe_vendeuse->isInEEC().", buyer country=".$societe_acheteuse->pays_code.", buyer in cee=".$societe_acheteuse->isInEEC().", idprod=".$idprod.", idprodfournprice=".$idprodfournprice.", SERVICE_ARE_ECOMMERCE_200238EC=".(! empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC)?$conf->global->SERVICES_ARE_ECOMMERCE_200238EC:''));
|
||||
|
||||
// Si vendeur non assujeti a TVA (tva_assuj vaut 0/1 ou franchise/reel)
|
||||
if (is_numeric($societe_vendeuse->tva_assuj) && ! $societe_vendeuse->tva_assuj)
|
||||
|
||||
@ -17,13 +17,13 @@
|
||||
*/
|
||||
|
||||
$module = $object->element;
|
||||
$permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page
|
||||
|
||||
// Special cases
|
||||
if ($module == 'propal') { $permission=$user->rights->propale->creer; }
|
||||
elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; }
|
||||
elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
|
||||
elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; }
|
||||
elseif (! isset($permission)) { $permission=$user->rights->$module->creer; } // If already defined by caller page
|
||||
|
||||
$companystatic=new Societe($db);
|
||||
$contactstatic=new Contact($db);
|
||||
@ -54,7 +54,7 @@ $userstatic=new User($db);
|
||||
<tr <?php echo $bc[$var]; ?>>
|
||||
<td nowrap="nowrap"><?php echo img_object('','user').' '.$langs->trans("Users"); ?></td>
|
||||
<td><?php echo $conf->global->MAIN_INFO_SOCIETE_NOM; ?></td>
|
||||
<td><?php echo $form->select_users($user->id,'userid',0,$userAlreadySelected); ?></td>
|
||||
<td><?php echo $form->select_users($user->id,'userid',0,(! empty($userAlreadySelected)?$userAlreadySelected:'')); ?></td>
|
||||
<td><?php echo $formcompany->selectTypeContact($object, '', 'type','internal'); ?></td>
|
||||
<td align="right" colspan="3" ><input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>"></td>
|
||||
</tr>
|
||||
|
||||
@ -26,14 +26,14 @@
|
||||
* \brief File of class to manage suppliers orders
|
||||
*/
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT."/core/class/commonorder.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage predefined suppliers products
|
||||
*/
|
||||
class CommandeFournisseur extends Commande
|
||||
class CommandeFournisseur extends CommonOrder
|
||||
{
|
||||
public $element='order_supplier';
|
||||
public $table_element='commande_fournisseur';
|
||||
@ -347,7 +347,7 @@ class CommandeFournisseur extends Commande
|
||||
if (! $error)
|
||||
{
|
||||
$this->oldref='';
|
||||
|
||||
|
||||
// Rename directory if dir was a temporary ref
|
||||
if (preg_match('/^[\(]?PROV/i', $this->ref))
|
||||
{
|
||||
@ -364,7 +364,7 @@ class CommandeFournisseur extends Commande
|
||||
if (@rename($dirsource, $dirdest))
|
||||
{
|
||||
$this->oldref = $oldref;
|
||||
|
||||
|
||||
dol_syslog("Rename ok");
|
||||
// Suppression ancien fichier PDF dans nouveau rep
|
||||
dol_delete_file($dirdest.'/'.$oldref.'.*');
|
||||
@ -1297,7 +1297,7 @@ class CommandeFournisseur extends Commande
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
// Appel des triggers
|
||||
@ -1309,7 +1309,7 @@ class CommandeFournisseur extends Commande
|
||||
}
|
||||
// Fin appel triggers
|
||||
}
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
// We remove directory
|
||||
@ -1337,7 +1337,7 @@ class CommandeFournisseur extends Commande
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG);
|
||||
@ -1821,7 +1821,7 @@ class CommandeFournisseur extends Commande
|
||||
/**
|
||||
* Classe de gestion des lignes de commande
|
||||
*/
|
||||
class CommandeFournisseurLigne extends OrderLine
|
||||
class CommandeFournisseurLigne
|
||||
{
|
||||
// From llx_commandedet
|
||||
var $qty;
|
||||
|
||||
@ -26,14 +26,14 @@
|
||||
* \brief File of class to manage suppliers invoices
|
||||
*/
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/core/class/commoninvoice.class.php");
|
||||
|
||||
|
||||
/**
|
||||
* \class FactureFournisseur
|
||||
* \brief Class to manage suppliers invoices
|
||||
*/
|
||||
class FactureFournisseur extends Facture
|
||||
class FactureFournisseur extends CommonInvoice
|
||||
{
|
||||
public $element='invoice_supplier';
|
||||
public $table_element='facture_fourn';
|
||||
@ -164,7 +164,7 @@ class FactureFournisseur extends Facture
|
||||
|
||||
|
||||
// Add object linked
|
||||
if (! $error && $this->id && $this->origin && $this->origin_id)
|
||||
if (! $error && $this->id && ! empty($this->origin) && ! empty($this->origin_id))
|
||||
{
|
||||
$ret = $this->add_object_linked();
|
||||
if (! $ret)
|
||||
@ -195,7 +195,7 @@ class FactureFournisseur extends Facture
|
||||
$this->lines[$i]->qty,
|
||||
$this->lines[$i]->fk_product,
|
||||
'HT',
|
||||
$this->lines[$i]->info_bits,
|
||||
(! empty($this->lines[$i]->info_bits)?$this->lines[$i]->info_bits:''),
|
||||
$this->lines[$i]->product_type
|
||||
);
|
||||
}
|
||||
@ -1363,7 +1363,7 @@ class FactureFournisseur extends Facture
|
||||
// Loop on each line of new invoice
|
||||
foreach($object->lines as $i => $line)
|
||||
{
|
||||
if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts
|
||||
if (isset($object->lines[$i]->info_bits) && ($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts
|
||||
{
|
||||
unset($object->lines[$i]);
|
||||
}
|
||||
|
||||
@ -242,9 +242,10 @@ class PaiementFourn extends Paiement
|
||||
* Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse
|
||||
* Si le paiement porte sur au moins une facture a "payee", on refuse
|
||||
*
|
||||
* @param int $notrigger No trigger
|
||||
* @return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function delete()
|
||||
function delete($notrigger=0)
|
||||
{
|
||||
$bank_line_id = $this->bank_line;
|
||||
|
||||
|
||||
@ -71,6 +71,7 @@ $hookmanager=new HookManager($db);
|
||||
$hookmanager->initHooks(array('ordersuppliercard'));
|
||||
|
||||
$mesg='';
|
||||
$errors=array();
|
||||
|
||||
$object = new CommandeFournisseur($db);
|
||||
|
||||
@ -576,7 +577,7 @@ else if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) /
|
||||
// Sauvegarde le dernier module choisi pour generer un document
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
|
||||
if ($_REQUEST['model'])
|
||||
{
|
||||
$object->setDocModel($user, $_REQUEST['model']);
|
||||
@ -609,7 +610,7 @@ else if ($action == 'remove_file' && $user->rights->fournisseur->commande->creer
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
|
||||
$langs->load("other");
|
||||
$upload_dir = $conf->fournisseur->commande->dir_output;
|
||||
$file = $upload_dir . '/' . GETPOST('file');
|
||||
@ -659,7 +660,7 @@ else if ($action == 'create' && $user->rights->fournisseur->commande->creer)
|
||||
/*
|
||||
* Add file in email form
|
||||
*/
|
||||
if ($_POST['addfile'])
|
||||
if (GETPOST('addfile'))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
||||
|
||||
@ -675,7 +676,7 @@ if ($_POST['addfile'])
|
||||
/*
|
||||
* Remove file in email form
|
||||
*/
|
||||
if (! empty($_POST['removedfile']))
|
||||
if (GETPOST('removedfile'))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
||||
|
||||
@ -1261,11 +1262,21 @@ if ($id > 0 || ! empty($ref))
|
||||
$var=!$var;
|
||||
|
||||
// Show product and description
|
||||
$type=$line->product_type?$line->product_type:$line->fk_product_type;
|
||||
$type=(! empty($line->product_type)?$line->product_type:(! empty($line->fk_product_type)?$line->fk_product_type:0));
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (! empty($line->date_start)) $type=1;
|
||||
if (! empty($line->date_end)) $type=1;
|
||||
$date_start='';
|
||||
$date_end='';
|
||||
if (! empty($line->date_start))
|
||||
{
|
||||
$date_start=$line->date_start;
|
||||
$type=1;
|
||||
}
|
||||
if (! empty($line->date_end))
|
||||
{
|
||||
$date_end=$line->date_end;
|
||||
$type=1;
|
||||
}
|
||||
|
||||
// Ligne en mode visu
|
||||
if ($action != 'editline' || $_GET['rowid'] != $line->id)
|
||||
@ -1286,7 +1297,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print $form->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
// Show range
|
||||
print_date_range($line->date_start,$line->date_end);
|
||||
print_date_range($date_start,$date_end);
|
||||
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($line->description && $line->description!=$product_static->libelle)?'<br>'.dol_htmlentitiesbr($line->description):'';
|
||||
@ -1300,7 +1311,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print $text.' '.nl2br($line->description);
|
||||
|
||||
// Show range
|
||||
print_date_range($line->date_start,$line->date_end);
|
||||
print_date_range($date_start,$date_end);
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
@ -1361,7 +1372,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print $form->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
// Show range
|
||||
print_date_range($line->date_start,$line->date_end);
|
||||
print_date_range($date_start,$date_end);
|
||||
print '<br>';
|
||||
}
|
||||
else
|
||||
@ -1427,23 +1438,23 @@ if ($id > 0 || ! empty($ref))
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
|
||||
$nbrows=ROWS_2;
|
||||
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
|
||||
$doleditor=new DolEditor('dp_desc',$_POST["dp_desc"],'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
|
||||
$doleditor=new DolEditor('dp_desc',GETPOST('dp_desc'),'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
|
||||
$doleditor->Create();
|
||||
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print $form->load_tva('tva_tx',($_POST["tva_tx"]?$_POST["tva_tx"]:-1),$soc,$mysoc);
|
||||
print $form->load_tva('tva_tx',(GETPOST('tva_tx')?GETPOST('tva_tx'):-1),$soc,$mysoc);
|
||||
print '</td>';
|
||||
print '<td align="right"><input type="text" name="pu" size="5" value="'.$_POST["pu"].'"></td>';
|
||||
print '<td align="right"><input type="text" name="qty" value="'.($_POST["qty"]?$_POST["qty"]:'1').'" size="2"></td>';
|
||||
print '<td align="right" nowrap="nowrap"><input type="text" name="remise_percent" size="1" value="'.($_POST["remise_percent"]?$_POST["remise_percent"]:$soc->remise_client).'">%</td>';
|
||||
print '<td align="right"><input type="text" name="pu" size="5" value="'.GETPOST('pu').'"></td>';
|
||||
print '<td align="right"><input type="text" name="qty" value="'.(GETPOST('qty')?GETPOST('qty'):'1').'" size="2"></td>';
|
||||
print '<td align="right" nowrap="nowrap"><input type="text" name="remise_percent" size="1" value="'.(GETPOST('remise_percent')?GETPOST('remise_percent'):$soc->remise_client).'">%</td>';
|
||||
print '<td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans('Add').'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
// Ajout de produits/services predefinis
|
||||
if ($conf->product->enabled || $conf->service->enabled)
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">';
|
||||
@ -1471,13 +1482,13 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td colspan="3">';
|
||||
|
||||
$form->select_produits_fournisseurs($object->fourn_id,'','idprodfournprice','',$filtre);
|
||||
$form->select_produits_fournisseurs($object->fourn_id,'','idprodfournprice');
|
||||
|
||||
if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '<br>';
|
||||
if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) print '<br>';
|
||||
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('filtre'=>$filtre,'htmlname'=>'idprodfournprice');
|
||||
$parameters=array('htmlname'=>'idprodfournprice');
|
||||
echo $hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action);
|
||||
}
|
||||
|
||||
@ -1485,12 +1496,12 @@ if ($id > 0 || ! empty($ref))
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
|
||||
$nbrows=ROWS_2;
|
||||
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
|
||||
$doleditor=new DolEditor('np_desc',$_POST["np_desc"],'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
|
||||
$doleditor=new DolEditor('np_desc',GETPOST('np_desc'),'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
|
||||
$doleditor->Create();
|
||||
|
||||
print '</td>';
|
||||
print '<td align="right"><input type="text" size="2" name="pqty" value="'.($_POST["pqty"]?$_POST["pqty"]:'1').'"></td>';
|
||||
print '<td align="right" nowrap="nowrap"><input type="text" size="1" name="p_remise_percent" value="'.($_POST["p_remise_percent"]?$_POST["p_remise_percent"]:$soc->remise_client).'">%</td>';
|
||||
print '<td align="right"><input type="text" size="2" name="pqty" value="'.(GETPOST('pqty')?GETPOST('pqty'):'1').'"></td>';
|
||||
print '<td align="right" nowrap="nowrap"><input type="text" size="1" name="p_remise_percent" value="'.(GETPOST('p_remise_percent')?GETPOST('p_remise_percent'):$soc->remise_client).'">%</td>';
|
||||
print '<td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans('Add').'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2012-2012 Vinicius Nogueira <viniciusvgn@gmail.com>
|
||||
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2012 Vinicius Nogueira <viniciusvgn@gmail.com>
|
||||
*
|
||||
* 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,7 +30,7 @@ require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
|
||||
|
||||
// Security check
|
||||
$orderid = isset($_GET["orderid"])?$_GET["orderid"]:'';
|
||||
$orderid = GETPOST('orderid');
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'commande_fournisseur', $orderid,'');
|
||||
|
||||
@ -40,7 +40,7 @@ $langs->load("orders");
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
*/
|
||||
|
||||
llxHeader('',$langs->trans("SuppliersOrdersArea"));
|
||||
|
||||
@ -48,7 +48,7 @@ $commandestatic = new CommandeFournisseur($db);
|
||||
$userstatic=new User($db);
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
print_barre_liste($langs->trans("SuppliersOrdersArea"), $page, "index.php", "", $sortfield, $sortorder, '', $num);
|
||||
print_fiche_titre($langs->trans("SuppliersOrdersArea"));
|
||||
|
||||
print '<table class="notopnoleftnoright" width="100%">';
|
||||
print '<tr valign="top"><td class="notopnoleft" width="30%">';
|
||||
@ -202,7 +202,7 @@ else
|
||||
* Draft orders
|
||||
*/
|
||||
|
||||
if ($conf->fournisseur->enabled)
|
||||
if (! empty($conf->fournisseur->enabled))
|
||||
{
|
||||
$sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
|
||||
@ -211,7 +211,7 @@ if ($conf->fournisseur->enabled)
|
||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||
$sql.= " AND c.entity = ".$conf->entity;
|
||||
$sql.= " AND c.fk_statut = 0";
|
||||
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
||||
if (! empty($socid)) $sql.= " AND c.fk_soc = ".$socid;
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
@ -307,7 +307,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX
|
||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||
$sql.= " AND c.entity = ".$conf->entity;
|
||||
//$sql.= " AND c.fk_statut > 2";
|
||||
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
|
||||
if (! empty($socid)) $sql .= " AND c.fk_soc = ".$socid;
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
$sql.= " ORDER BY c.tms DESC";
|
||||
$sql.= $db->plimit($max, 0);
|
||||
|
||||
@ -42,6 +42,7 @@ $langs->load('suppliers');
|
||||
$langs->load('companies');
|
||||
|
||||
$mesg='';
|
||||
$errors=array();
|
||||
$id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int'));
|
||||
$action = GETPOST("action");
|
||||
$confirm = GETPOST("confirm");
|
||||
@ -52,7 +53,8 @@ $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty(
|
||||
$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$socid='';
|
||||
if (! empty($user->societe_id)) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
@ -404,7 +406,7 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer)
|
||||
// Modification d'une ligne
|
||||
elseif ($action == 'update_line')
|
||||
{
|
||||
if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification
|
||||
if (GETPOST('etat') == '1' && ! GETPOST('cancel')) // si on valide la modification
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
@ -420,7 +422,7 @@ elseif ($action == 'update_line')
|
||||
$price_base_type='TTC';
|
||||
}
|
||||
|
||||
if ($_POST['idprod'])
|
||||
if (GETPOST('idprod'))
|
||||
{
|
||||
$prod = new Product($db);
|
||||
$prod->fetch($_POST['idprod']);
|
||||
@ -440,7 +442,7 @@ elseif ($action == 'update_line')
|
||||
$localtax1tx= get_localtax($_POST['tauxtva'], 1, $object->thirdparty);
|
||||
$localtax2tx= get_localtax($_POST['tauxtva'], 2, $object->thirdparty);
|
||||
|
||||
$result=$object->updateline($_GET['lineid'], $label, $pu, $_POST['tauxtva'], $localtax1tx, $localtax2tx, $_POST['qty'], $_POST['idprod'], $price_base_type, 0, $type);
|
||||
$result=$object->updateline(GETPOST('lineid'), $label, $pu, GETPOST('tauxtva'), $localtax1tx, $localtax2tx, GETPOST('qty'), GETPOST('idprod'), $price_base_type, 0, $type);
|
||||
if ($result >= 0)
|
||||
{
|
||||
unset($_POST['label']);
|
||||
@ -607,7 +609,7 @@ elseif ($action == 'reopen' && $user->rights->fournisseur->facture->creer)
|
||||
}
|
||||
|
||||
// Add file in email form
|
||||
if ($_POST['addfile'])
|
||||
if (GETPOST('addfile'))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
||||
|
||||
@ -1277,13 +1279,13 @@ else
|
||||
|
||||
// Ref
|
||||
print '<tr><td nowrap="nowrap" width="20%">'.$langs->trans("Ref").'</td><td colspan="4">';
|
||||
print $form->showrefnav($object,'id','',1,'rowid','ref',$morehtmlref);
|
||||
print $form->showrefnav($object,'id','',1,'rowid','ref');
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Ref supplier
|
||||
print '<tr><td>'.$form->editfieldkey("RefSupplier",'ref_supplier',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).'</td><td colspan="4">';
|
||||
print $form->editfieldval("RefSupplier",'ref_supplier',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer));
|
||||
print '<tr><td>'.$form->editfieldkey("RefSupplier",'facnumber',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).'</td><td colspan="4">';
|
||||
print $form->editfieldval("RefSupplier",'facnumber',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer));
|
||||
print '</td></tr>';
|
||||
|
||||
// Third party
|
||||
@ -1322,7 +1324,7 @@ else
|
||||
}
|
||||
print ')';
|
||||
}
|
||||
if ($facidnext > 0)
|
||||
if (isset($facidnext) && $facidnext > 0)
|
||||
{
|
||||
$facthatreplace=new FactureFournisseur($db);
|
||||
$facthatreplace->fetch($facidnext);
|
||||
@ -1548,11 +1550,21 @@ else
|
||||
}
|
||||
|
||||
// Show product and description
|
||||
$type=$object->lines[$i]->product_type?$object->lines[$i]->product_type:$object->lines[$i]->fk_product_type;
|
||||
$type=(! empty($object->lines[$i]->product_type)?$object->lines[$i]->product_type:(! empty($object->lines[$i]->fk_product_type)?$object->lines[$i]->fk_product_type:0));
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (! empty($object->lines[$i]->date_start)) $type=1;
|
||||
if (! empty($object->lines[$i]->date_end)) $type=1;
|
||||
$date_start='';
|
||||
$date_end='';
|
||||
if (! empty($object->lines[$i]->date_start))
|
||||
{
|
||||
$date_start=$object->lines[$i]->date_start;
|
||||
$type=1;
|
||||
}
|
||||
if (! empty($object->lines[$i]->date_end))
|
||||
{
|
||||
$date_end=$object->lines[$i]->date_end;
|
||||
$type=1;
|
||||
}
|
||||
|
||||
$var=!$var;
|
||||
|
||||
@ -1632,7 +1644,7 @@ else
|
||||
print $form->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
// Show range
|
||||
print_date_range($object->lines[$i]->date_start,$object->lines[$i]->date_end);
|
||||
print_date_range($date_start,$date_end);
|
||||
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($object->lines[$i]->description && $object->lines[$i]->description!=$product_static->libelle)?'<br>'.dol_htmlentitiesbr($object->lines[$i]->description):'';
|
||||
@ -1646,7 +1658,7 @@ else
|
||||
print $text.' '.nl2br($object->lines[$i]->description);
|
||||
|
||||
// Show range
|
||||
print_date_range($object->lines[$i]->date_start,$object->lines[$i]->date_end);
|
||||
print_date_range($date_start,$date_end);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
@ -1723,7 +1735,7 @@ else
|
||||
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print $form->load_tva('tauxtva',($_POST["tauxtva"]?$_POST["tauxtva"]:-1),$societe,$mysoc);
|
||||
print $form->load_tva('tauxtva',(GETPOST('tauxtva')?GETPOST('tauxtva'):-1),$societe,$mysoc);
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print '<input size="4" name="amount" type="text">';
|
||||
@ -1740,7 +1752,7 @@ else
|
||||
print '</form>';
|
||||
|
||||
// Ajout de produits/services predefinis
|
||||
if ($conf->product->enabled || $conf->service->enabled)
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4">';
|
||||
@ -1766,11 +1778,11 @@ else
|
||||
$var=! $var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td colspan="4">';
|
||||
$form->select_produits_fournisseurs($object->socid,'','idprodfournprice','',$filtre);
|
||||
$form->select_produits_fournisseurs($object->socid,'','idprodfournprice');
|
||||
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('filtre'=>$filtre,'htmlname'=>'idprodfournprice');
|
||||
$parameters=array('htmlname'=>'idprodfournprice');
|
||||
echo $hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action);
|
||||
}
|
||||
|
||||
@ -1882,9 +1894,10 @@ else
|
||||
$urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id;
|
||||
$genallowed=$user->rights->fournisseur->facture->creer;
|
||||
$delallowed=$user->rights->fournisseur->facture->supprimer;
|
||||
$modelpdf=(! empty($object->modelpdf)?$object->modelpdf:'');
|
||||
|
||||
print '<br>';
|
||||
print $formfile->showdocuments('facture_fournisseur',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,0,0,'','','',$societe->default_lang);
|
||||
print $formfile->showdocuments('facture_fournisseur',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,0,0,'','','',$societe->default_lang);
|
||||
$somethingshown=$formfile->numoffiles;
|
||||
|
||||
/*
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2012-2012 Vinicius Nogueira <viniciusvgn@gmail.com>
|
||||
* Copyright (C) 2012 Vinicius Nogueira <viniciusvgn@gmail.com>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -104,9 +104,9 @@ if ($user->rights->fournisseur->facture->lire)
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql .= " AND s.rowid = ".$socid;
|
||||
|
||||
if ($_GET["filtre"])
|
||||
if (GETPOST('filtre'))
|
||||
{
|
||||
$filtrearr = explode(",", $_GET["filtre"]);
|
||||
$filtrearr = explode(",", GETPOST('filtre'));
|
||||
foreach ($filtrearr as $fil)
|
||||
{
|
||||
$filt = explode(":", $fil);
|
||||
@ -116,16 +116,16 @@ if ($user->rights->fournisseur->facture->lire)
|
||||
|
||||
if ($search_ref)
|
||||
{
|
||||
$sql .= " AND f.rowid like '%".$search_ref."%'";
|
||||
$sql .= " AND f.rowid LIKE '%".$search_ref."%'";
|
||||
}
|
||||
if ($search_ref_supplier)
|
||||
{
|
||||
$sql .= " AND f.facnumber like '%".$search_ref_supplier."%'";
|
||||
$sql .= " AND f.facnumber LIKE '%".$search_ref_supplier."%'";
|
||||
}
|
||||
|
||||
if ($search_societe)
|
||||
{
|
||||
$sql .= " AND s.nom like '%".$search_societe."%'";
|
||||
$sql .= " AND s.nom LIKE '%".$search_societe."%'";
|
||||
}
|
||||
|
||||
if ($search_montant_ht)
|
||||
@ -138,9 +138,9 @@ if ($user->rights->fournisseur->facture->lire)
|
||||
$sql .= " AND f.total_ttc = '".$search_montant_ttc."'";
|
||||
}
|
||||
|
||||
if (dol_strlen($_POST["sf_ref"]) > 0)
|
||||
if (dol_strlen(GETPOST('sf_re')) > 0)
|
||||
{
|
||||
$sql .= " AND f.facnumber like '%".$_POST["sf_ref"]."%'";
|
||||
$sql .= " AND f.facnumber LIKE '%".GETPOST('sf_re')."%'";
|
||||
}
|
||||
$sql.= " GROUP BY f.facnumber, f.rowid, f.total_ht, f.total_ttc, f.datef, f.date_lim_reglement, f.paye, f.fk_statut, s.rowid, s.nom";
|
||||
|
||||
@ -162,16 +162,16 @@ if ($user->rights->fournisseur->facture->lire)
|
||||
|
||||
$param ='';
|
||||
if ($socid) $param.="&socid=".$socid;
|
||||
|
||||
|
||||
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
|
||||
if ($search_ref_supplier) $param.='&search_ref_supplier='.urlencode($search_ref_supplier);
|
||||
if ($search_societe) $param.='&search_societe='.urlencode($search_societe);
|
||||
if ($search_montant_ht) $param.='&search_montant_ht='.urlencode($search_montant_ht);
|
||||
if ($search_montant_ttc) $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
|
||||
|
||||
|
||||
$param.=($option?"&option=".$option:"");
|
||||
if ($late) $param.='&late='.urlencode($late);
|
||||
$urlsource.=str_replace('&','&',$param);
|
||||
if (! empty($late)) $param.='&late='.urlencode($late);
|
||||
$urlsource=str_replace('&','&',$param);
|
||||
|
||||
$titre=($socid?$langs->trans("BillsSuppliersUnpaidForCompany",$soc->nom):$langs->trans("BillsSuppliersUnpaid"));
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.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
|
||||
@ -112,9 +112,9 @@ if ($socid)
|
||||
{
|
||||
$sql .= " AND s.rowid = ".$socid;
|
||||
}
|
||||
if ($_GET["filtre"])
|
||||
if (GETPOST('filtre'))
|
||||
{
|
||||
$filtrearr = explode(",", $_GET["filtre"]);
|
||||
$filtrearr = explode(",", GETPOST('filtre'));
|
||||
foreach ($filtrearr as $fil)
|
||||
{
|
||||
$filt = explode(":", $fil);
|
||||
@ -124,11 +124,11 @@ if ($_GET["filtre"])
|
||||
|
||||
if (GETPOST("search_ref"))
|
||||
{
|
||||
$sql .= " AND fac.rowid like '%".$db->escape(GETPOST("search_ref"))."%'";
|
||||
$sql .= " AND fac.rowid LIKE '%".$db->escape(GETPOST("search_ref"))."%'";
|
||||
}
|
||||
if (GETPOST("search_ref_supplier"))
|
||||
{
|
||||
$sql .= " AND fac.facnumber like '%".$db->escape(GETPOST("search_ref_supplier"))."%'";
|
||||
$sql .= " AND fac.facnumber LIKE '%".$db->escape(GETPOST("search_ref_supplier"))."%'";
|
||||
}
|
||||
if ($month > 0)
|
||||
{
|
||||
@ -143,12 +143,12 @@ else if ($year > 0)
|
||||
}
|
||||
if (GETPOST("search_libelle"))
|
||||
{
|
||||
$sql .= " AND fac.libelle like '%".$db->escape(GETPOST("search_libelle"))."%'";
|
||||
$sql .= " AND fac.libelle LIKE '%".$db->escape(GETPOST("search_libelle"))."%'";
|
||||
}
|
||||
|
||||
if (GETPOST("search_societe"))
|
||||
{
|
||||
$sql .= " AND s.nom like '%".$db->escape(GETPOST("search_societe"))."%'";
|
||||
$sql .= " AND s.nom LIKE '%".$db->escape(GETPOST("search_societe"))."%'";
|
||||
}
|
||||
|
||||
if (GETPOST("search_montant_ht"))
|
||||
@ -268,7 +268,8 @@ if ($resql)
|
||||
// Affiche statut de la facture
|
||||
print '<td align="right" nowrap="nowrap">';
|
||||
// TODO le montant deja paye objp->am n'est pas definie
|
||||
print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$objp->am);
|
||||
//print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$objp->am);
|
||||
print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5);
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
@ -262,7 +262,7 @@ if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC'))
|
||||
// Set default language (must be after the setValues of $conf)
|
||||
if (! defined('NOREQUIRETRAN'))
|
||||
{
|
||||
$langs->setDefaultLang($conf->global->MAIN_LANG_DEFAULT);
|
||||
$langs->setDefaultLang((! empty($conf->global->MAIN_LANG_DEFAULT)?$conf->global->MAIN_LANG_DEFAULT:''));
|
||||
}
|
||||
|
||||
if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user