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

This commit is contained in:
Laurent Destailleur 2014-03-15 15:10:45 +01:00
commit 6a72ebbe76
19 changed files with 244 additions and 708 deletions

View File

@ -253,6 +253,7 @@ class Commande extends CommonOrder
if ($this->lines[$i]->fk_product > 0) if ($this->lines[$i]->fk_product > 0)
{ {
$mouvP = new MouvementStock($this->db); $mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
// We decrement stock of product (and sub-products) // We decrement stock of product (and sub-products)
$result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr",$num)); $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr",$num));
if ($result < 0) { $error++; } if ($result < 0) { $error++; }

View File

@ -643,8 +643,37 @@ else if ($action == 'add' && $user->rights->facture->creer) {
$id = $object->create($user); $id = $object->create($user);
if(GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) {
$facture_source = new Facture($db); // fetch origin object
if($facture_source->fetch($object->fk_facture_source)>0) {
foreach($facture_source->lines as $line) {
$line->fk_facture = $object->id;
$line->subprice =-$line->subprice; // invert price for object
$line->pa_ht = -$line->pa_ht;
$line->total_ht=-$line->total_ht;
$line->total_tva=-$line->total_tva;
$line->total_ttc=-$line->total_ttc;
$line->total_localtax1=-$line->total_localtax1;
$line->total_localtax2=-$line->total_localtax2;
$line->insert();
$object->lines[] = $line; // insert new line in current object
}
$object->update_price(1);
}
}
// Add predefined lines // Add predefined lines
for($i = 1; $i <= $NBLINES; $i ++) { /*
TODO delete
for($i = 1; $i <= $NBLINES; $i ++) {
if ($_POST ['idprod' . $i]) { if ($_POST ['idprod' . $i]) {
$product = new Product($db); $product = new Product($db);
$product->fetch($_POST ['idprod' . $i]); $product->fetch($_POST ['idprod' . $i]);
@ -652,7 +681,7 @@ else if ($action == 'add' && $user->rights->facture->creer) {
$endday = dol_mktime(12, 0, 0, $_POST ['date_end' . $i . 'month'], $_POST ['date_end' . $i . 'day'], $_POST ['date_end' . $i . 'year']); $endday = dol_mktime(12, 0, 0, $_POST ['date_end' . $i . 'month'], $_POST ['date_end' . $i . 'day'], $_POST ['date_end' . $i . 'year']);
$result = $object->addline($product->description, $product->price, $_POST ['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST ['idprod' . $i], $_POST ['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); $result = $object->addline($product->description, $product->price, $_POST ['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST ['idprod' . $i], $_POST ['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
} }
} }*/
} }
} }
@ -2000,12 +2029,12 @@ if ($action == 'create')
if (empty($origin) && $socid > 0) if (empty($origin) && $socid > 0)
{ {
// Credit note // Credit note
print '<tr height="18"><td valign="middle">'; print '<tr height="18"><td valign="top">';
print '<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked=true' : ''); print '<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked=true' : '');
if (! $optionsav) if (! $optionsav)
print ' disabled="disabled"'; print ' disabled="disabled"';
print '>'; print '>';
print '</td><td valign="middle">'; print '</td><td valign="top">';
print '<script type="text/javascript" language="javascript"> print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
jQuery("#fac_avoir").click(function() { jQuery("#fac_avoir").click(function() {
@ -2028,6 +2057,9 @@ if ($action == 'create')
$text .= '</select>'; $text .= '</select>';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1); $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1);
print $desc; print $desc;
print '&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').attr(\'checked\',\'checked\') }" /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
print '</td></tr>' . "\n"; print '</td></tr>' . "\n";
} }

View File

@ -1329,6 +1329,7 @@ class Facture extends CommonInvoice
if ($this->lines[$i]->fk_product > 0) if ($this->lines[$i]->fk_product > 0)
{ {
$mouvP = new MouvementStock($this->db); $mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
// We decrease stock for product // We decrease stock for product
if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr",$this->ref));
else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value
@ -1794,6 +1795,7 @@ class Facture extends CommonInvoice
if ($this->lines[$i]->fk_product > 0) if ($this->lines[$i]->fk_product > 0)
{ {
$mouvP = new MouvementStock($this->db); $mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
// We decrease stock for product // We decrease stock for product
if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num));
else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num));
@ -1916,6 +1918,7 @@ class Facture extends CommonInvoice
if ($this->lines[$i]->fk_product > 0) if ($this->lines[$i]->fk_product > 0)
{ {
$mouvP = new MouvementStock($this->db); $mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
// We decrease stock for product // We decrease stock for product
if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref));
else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value

View File

@ -35,9 +35,9 @@ abstract class DoliDB implements Database
//! Database label //! Database label
static $label; static $label;
//! Charset used to force charset when creating database //! Charset used to force charset when creating database
public $forcecharset; public $forcecharset='utf8';
//! Collate used to force collate when creating database //! Collate used to force collate when creating database
public $forcecollate; public $forcecollate='utf8_general_ci';
//! Min database version //! Min database version
static $versionmin; static $versionmin;
//! Resultset of last query //! Resultset of last query
@ -64,7 +64,96 @@ abstract class DoliDB implements Database
public $ok; public $ok;
public $error; public $error;
/**
* Format a SQL IF
*
* @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
* @param string $resok resultat si test egal
* @param string $resko resultat si test non egal
* @return string SQL string
*/
function ifsql($test,$resok,$resko)
{
return 'IF('.$test.','.$resok.','.$resko.')';
}
/**
* Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica
*
* @param string $param Date TMS to convert
* @return string Date in a string YYYYMMDDHHMMSS
*/
function idate($param)
{
return dol_print_date($param,"%Y%m%d%H%M%S");
}
/**
* Return last error code
*
* @return string lasterrno
*/
function lasterrno()
{
return $this->lasterrno;
}
/**
* Start transaction
*
* @return int 1 if transaction successfuly opened or already opened, 0 if error
*/
function begin()
{
if (! $this->transaction_opened)
{
$ret=$this->query("BEGIN");
if ($ret)
{
$this->transaction_opened++;
dol_syslog("BEGIN Transaction",LOG_DEBUG);
dol_syslog('',0,1);
}
return $ret;
}
else
{
$this->transaction_opened++;
dol_syslog('',0,1);
return 1;
}
}
/**
* Return version of database server into an array
*
* @return array Version array
*/
function getVersionArray()
{
return explode('.',$this->getVersion());
}
/**
* Return label of manager
*
* @return string Label
*/
function getLabel()
{
return $this->label;
}
/**
* Return last request executed with query()
*
* @return string Last query
*/
function lastquery()
{
return $this->lastquery;
}
/** /**
* Define sort criteria of request * Define sort criteria of request
@ -94,5 +183,42 @@ abstract class DoliDB implements Database
return ''; return '';
} }
} }
/**
* Return last error label
*
* @return string lasterror
*/
function lasterror()
{
return $this->lasterror;
}
/**
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
* 19700101020000 -> 3600 with TZ+1 and gmt=0
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
*
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @return date Date TMS
*/
function jdate($string, $gm=false)
{
$string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000';
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
return $date;
}
/**
* Return last query in error
*
* @return string lastqueryerror
*/
function lastqueryerror()
{
return $this->lastqueryerror;
}
} }

View File

@ -30,8 +30,6 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php';
*/ */
class DoliDBMssql extends DoliDB class DoliDBMssql extends DoliDB
{ {
//! Database handler
var $db;
//! Database type //! Database type
public $type='mssql'; public $type='mssql';
//! Database label //! Database label
@ -42,30 +40,8 @@ class DoliDBMssql extends DoliDB
var $forcecollate='latin1_swedish_ci'; // Can't be static as it may be forced with a dynamic value var $forcecollate='latin1_swedish_ci'; // Can't be static as it may be forced with a dynamic value
//! Version min database //! Version min database
static $versionmin=array(2000); static $versionmin=array(2000);
//! Resultset of last request //! Resultset of last query
private $_results; private $_results;
//! 1 si connecte, 0 sinon
var $connected;
//! 1 si base selectionne, 0 sinon
var $database_selected;
//! Nom base selectionnee
var $database_name;
//! Nom user base
var $database_user;
//! >=1 if a transaction is opened, 0 otherwise
var $transaction_opened;
//! Derniere requete executee
var $lastquery;
//! Derniere requete executee avec echec
var $lastqueryerror;
//! Message erreur mysql
var $lasterror;
//! Message erreur mysql
var $lasterrno;
var $ok;
var $error;
/** /**
* Constructor. * Constructor.
@ -197,16 +173,6 @@ class DoliDBMssql extends DoliDB
return $this->db; return $this->db;
} }
/**
* Return label of manager
*
* @return string Label
*/
function getLabel()
{
return $this->label;
}
/** /**
* Return version of database server * Return version of database server
* *
@ -219,17 +185,6 @@ class DoliDBMssql extends DoliDB
return $version['computed']; return $version['computed'];
} }
/**
* Return version of database server into an array
*
* @return array Version array
*/
function getVersionArray()
{
return explode('.',$this->getVersion());
}
/** /**
* Return version of database client driver * Return version of database client driver
* *
@ -553,77 +508,6 @@ class DoliDBMssql extends DoliDB
return dol_print_date($param,"%Y-%m-%d %H:%M:%S"); return dol_print_date($param,"%Y-%m-%d %H:%M:%S");
} }
/**
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
* 19700101020000 -> 3600 with TZ+1 and gmt=0
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
*
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @return date Date TMS
*/
function jdate($string, $gm=false)
{
$string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000';
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
return $date;
}
/**
* Format a SQL IF
*
* @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
* @param string $resok resultat si test egal
* @param string $resko resultat si test non egal
* @return string SQL string
*/
function ifsql($test,$resok,$resko)
{
return 'IF('.$test.','.$resok.','.$resko.')';
}
/**
* Return last request executed with query()
*
* @return string Last query
*/
function lastquery()
{
return $this->lastquery;
}
/**
* Return last query in error
*
* @return string lastqueryerror
*/
function lastqueryerror()
{
return $this->lastqueryerror;
}
/**
* Return last error label
*
* @return string lasterror
*/
function lasterror()
{
return $this->lasterror;
}
/**
* Return last error code
*
* @return string lasterrno
*/
function lasterrno()
{
return $this->lasterrno;
}
/** /**
* Return generic error code of last operation. * Return generic error code of last operation.
* *

View File

@ -31,42 +31,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php';
*/ */
class DoliDBMysql extends DoliDB class DoliDBMysql extends DoliDB
{ {
//! Database handler
var $db;
//! Database type //! Database type
public $type='mysql'; public $type='mysql';
//! Database label //! Database label
static $label='MySQL'; static $label='MySQL';
//! Charset used to force charset when creating database
var $forcecharset='utf8'; // latin1, utf8. Can't be static as it may be forced with a dynamic value
//! Collate used to force collate when creating database
var $forcecollate='utf8_general_ci'; // latin1_swedish_ci, utf8_general_ci. Can't be static as it may be forced with a dynamic value
//! Version min database //! Version min database
static $versionmin=array(4,1,0); static $versionmin=array(4,1,0);
//! Resultset of last request //! Resultset of last query
private $_results; private $_results;
//! 1 if connected, 0 else
var $connected;
//! 1 if database selected, 0 else
var $database_selected;
//! Database name selected
var $database_name;
//! Nom user base
var $database_user;
//! >=1 if a transaction is opened, 0 otherwise
var $transaction_opened;
//! Last executed request
var $lastquery;
//! Last failed executed request
var $lastqueryerror;
//! Message erreur mysql
var $lasterror;
//! Message erreur mysql
var $lasterrno;
var $ok;
var $error;
/** /**
* Constructor. * Constructor.
@ -229,16 +201,6 @@ class DoliDBMysql extends DoliDB
return $this->db; return $this->db;
} }
/**
* Return label of manager
*
* @return string Label
*/
function getLabel()
{
return $this->label;
}
/** /**
* Return version of database server * Return version of database server
* *
@ -249,16 +211,6 @@ class DoliDBMysql extends DoliDB
return mysql_get_server_info($this->db); return mysql_get_server_info($this->db);
} }
/**
* Return version of database server into an array
*
* @return array Version array
*/
function getVersionArray()
{
return explode('.',$this->getVersion());
}
/** /**
* Return version of database client driver * Return version of database client driver
* *
@ -287,33 +239,6 @@ class DoliDBMysql extends DoliDB
return false; return false;
} }
/**
* Start transaction
*
* @return int 1 if transaction successfuly opened or already opened, 0 if error
*/
function begin()
{
if (! $this->transaction_opened)
{
$ret=$this->query("BEGIN");
if ($ret)
{
$this->transaction_opened++;
dol_syslog("BEGIN Transaction",LOG_DEBUG);
dol_syslog('',0,1);
}
return $ret;
}
else
{
$this->transaction_opened++;
dol_syslog('',0,1);
return 1;
}
}
/** /**
* Validate a database transaction * Validate a database transaction
* *
@ -518,90 +443,6 @@ class DoliDBMysql extends DoliDB
return addslashes($stringtoencode); return addslashes($stringtoencode);
} }
/**
* Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica
*
* @param string $param Date TMS to convert
* @return string Date in a string YYYYMMDDHHMMSS
*/
function idate($param)
{
return dol_print_date($param,"%Y%m%d%H%M%S");
}
/**
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
* 19700101020000 -> 3600 with TZ+1 and gmt=0
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
*
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @return date Date TMS
*/
function jdate($string, $gm=false)
{
$string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000';
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
return $date;
}
/**
* Format a SQL IF
*
* @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
* @param string $resok resultat si test egal
* @param string $resko resultat si test non egal
* @return string SQL string
*/
function ifsql($test,$resok,$resko)
{
return 'IF('.$test.','.$resok.','.$resko.')';
}
/**
* Return last request executed with query()
*
* @return string Last query
*/
function lastquery()
{
return $this->lastquery;
}
/**
* Return last query in error
*
* @return string lastqueryerror
*/
function lastqueryerror()
{
return $this->lastqueryerror;
}
/**
* Return last error label
*
* @return string lasterror
*/
function lasterror()
{
return $this->lasterror;
}
/**
* Return last error code
*
* @return string lasterrno
*/
function lasterrno()
{
return $this->lasterrno;
}
/** /**
* Return generic error code of last operation. * Return generic error code of last operation.
* *

View File

@ -31,42 +31,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php';
*/ */
class DoliDBMysqli extends DoliDB class DoliDBMysqli extends DoliDB
{ {
//! Database handler
var $db;
//! Database type //! Database type
public $type='mysqli'; public $type='mysqli';
//! Database label //! Database label
static $label='MySQL'; static $label='MySQL';
//! Charset used to force charset when creating database
var $forcecharset='utf8'; // latin1, utf8. Can't be static as it may be forced with a dynamic value
//! Collate used to force collate when creating database
var $forcecollate='utf8_general_ci'; // latin1_swedish_ci, utf8_general_ci. Can't be static as it may be forced with a dynamic value
//! Version min database //! Version min database
static $versionmin=array(4,1,0); static $versionmin=array(4,1,0);
//! Resultset of last request //! Resultset of last query
private $_results; private $_results;
//! 1 if connected, 0 else
var $connected;
//! 1 if database selected, 0 else
var $database_selected;
//! Database name selected
var $database_name;
//! Nom user base
var $database_user;
//! >=1 if a transaction is opened, 0 otherwise
var $transaction_opened;
//! Last executed request
var $lastquery;
//! Last failed executed request
var $lastqueryerror;
//! Message erreur mysql
var $lasterror;
//! Message erreur mysql
var $lasterrno;
var $ok;
var $error;
/** /**
* Constructor. * Constructor.
@ -233,16 +205,6 @@ class DoliDBMysqli extends DoliDB
return $this->db; return $this->db;
} }
/**
* Return label of manager
*
* @return string Label
*/
function getLabel()
{
return $this->label;
}
/** /**
* Return version of database server * Return version of database server
* *
@ -253,16 +215,6 @@ class DoliDBMysqli extends DoliDB
return mysqli_get_server_info($this->db); return mysqli_get_server_info($this->db);
} }
/**
* Return version of database server into an array
*
* @return array Version array
*/
function getVersionArray()
{
return explode('.',$this->getVersion());
}
/** /**
* Return version of database client driver * Return version of database client driver
* *
@ -291,33 +243,6 @@ class DoliDBMysqli extends DoliDB
return false; return false;
} }
/**
* Start transaction
*
* @return int 1 if transaction successfuly opened or already opened, 0 if error
*/
function begin()
{
if (! $this->transaction_opened)
{
$ret=$this->query("BEGIN");
if ($ret)
{
$this->transaction_opened++;
dol_syslog("BEGIN Transaction",LOG_DEBUG);
dol_syslog('',0,1);
}
return $ret;
}
else
{
$this->transaction_opened++;
dol_syslog('',0,1);
return 1;
}
}
/** /**
* Validate a database transaction * Validate a database transaction
* *
@ -529,89 +454,6 @@ class DoliDBMysqli extends DoliDB
return addslashes($stringtoencode); return addslashes($stringtoencode);
} }
/**
* Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica
*
* @param string $param Date TMS to convert
* @return string Date in a string YYYYMMDDHHMMSS
*/
function idate($param)
{
return dol_print_date($param,"%Y%m%d%H%M%S");
}
/**
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
* 19700101020000 -> 3600 with TZ+1 and gmt=0
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
*
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @return date Date TMS
*/
function jdate($string, $gm=false)
{
$string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000';
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
return $date;
}
/**
* Format a SQL IF
*
* @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
* @param string $resok resultat si test egal
* @param string $resko resultat si test non egal
* @return string SQL string
*/
function ifsql($test,$resok,$resko)
{
return 'IF('.$test.','.$resok.','.$resko.')';
}
/**
* Return last request executed with query()
*
* @return string Last query
*/
function lastquery()
{
return $this->lastquery;
}
/**
* Renvoie la derniere requete en erreur
*
* @return string lastqueryerror
*/
function lastqueryerror()
{
return $this->lastqueryerror;
}
/**
* Renvoie le libelle derniere erreur
*
* @return string lasterror
*/
function lasterror()
{
return $this->lasterror;
}
/**
* Renvoie le code derniere erreur
*
* @return string lasterrno
*/
function lasterrno()
{
return $this->lasterrno;
}
/** /**
* Return generic error code of last operation. * Return generic error code of last operation.
* *

View File

@ -34,8 +34,6 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php';
*/ */
class DoliDBPgsql extends DoliDB class DoliDBPgsql extends DoliDB
{ {
//! Database handler
var $db;
//! Database type //! Database type
public $type='pgsql'; // Name of manager public $type='pgsql'; // Name of manager
//! Database label //! Database label
@ -46,29 +44,9 @@ class DoliDBPgsql extends DoliDB
var $forcecollate=''; // Can't be static as it may be forced with a dynamic value var $forcecollate=''; // Can't be static as it may be forced with a dynamic value
//! Version min database //! Version min database
static $versionmin=array(8,4,0); // Version min database static $versionmin=array(8,4,0); // Version min database
//! Resultset of last query
//! Resultset of last request
private $_results; private $_results;
var $connected; // 1 si connecte, 0 sinon
var $database_selected; // 1 si base selectionne, 0 sinon
var $database_name; //! Nom base selectionnee
var $database_user; //! Nom user base
//! >=1 if a transaction is opened, 0 otherwise
var $transaction_opened;
var $lastquery;
// Saved last error
var $lastqueryerror;
var $lasterror;
var $lasterrno;
var $unescapeslashquot=0; // By default we do not force the unescape of \'. This is used only to process sql with mysql escaped data.
var $standard_conforming_strings=1; // Database has option standard_conforming_strings to on
var $ok;
var $error;
/** /**
* Constructor. * Constructor.
* This create an opened connexion to a database server and eventually to a database * This create an opened connexion to a database server and eventually to a database
@ -424,16 +402,6 @@ class DoliDBPgsql extends DoliDB
return $this->db; return $this->db;
} }
/**
* Return label of manager
*
* @return string Label
*/
function getLabel()
{
return $this->label;
}
/** /**
* Return version of database server * Return version of database server
* *
@ -450,16 +418,6 @@ class DoliDBPgsql extends DoliDB
return ''; return '';
} }
/**
* Return version of database server into an array
*
* @return array Version array
*/
function getVersionArray()
{
return explode('.',$this->getVersion());
}
/** /**
* Return version of database client driver * Return version of database client driver
* *
@ -752,23 +710,6 @@ class DoliDBPgsql extends DoliDB
return dol_print_date($param,"%Y-%m-%d %H:%M:%S"); return dol_print_date($param,"%Y-%m-%d %H:%M:%S");
} }
/**
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
* 19700101020000 -> 3600 with TZ+1 and gmt=0
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
*
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @return date Date TMS
*/
function jdate($string, $gm=false)
{
$string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000';
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
return $date;
}
/** /**
* Format a SQL IF * Format a SQL IF
* *
@ -782,47 +723,6 @@ class DoliDBPgsql extends DoliDB
return '(CASE WHEN '.$test.' THEN '.$resok.' ELSE '.$resko.' END)'; return '(CASE WHEN '.$test.' THEN '.$resok.' ELSE '.$resko.' END)';
} }
/**
* Renvoie la derniere requete soumise par la methode query()
*
* @return lastquery
*/
function lastquery()
{
return $this->lastquery;
}
/**
* Renvoie la derniere requete en erreur
*
* @return string lastqueryerror
*/
function lastqueryerror()
{
return $this->lastqueryerror;
}
/**
* Renvoie le libelle derniere erreur
*
* @return string lasterror
*/
function lasterror()
{
return $this->lasterror;
}
/**
* Renvoie le code derniere erreur
*
* @return string lasterrno
*/
function lasterrno()
{
return $this->lasterrno;
}
/** /**
* Renvoie le code erreur generique de l'operation precedente. * Renvoie le code erreur generique de l'operation precedente.
* *

View File

@ -31,42 +31,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php';
*/ */
class DoliDBSqlite extends DoliDB class DoliDBSqlite extends DoliDB
{ {
//! Database handler
var $db;
//! Database type //! Database type
public $type='sqlite'; public $type='sqlite';
//! Database label //! Database label
static $label='PDO Sqlite'; static $label='PDO Sqlite';
//! Charset used to force charset when creating database
var $forcecharset='utf8'; // latin1, utf8. Can't be static as it may be forced with a dynamic value
//! Collate used to force collate when creating database
var $forcecollate='utf8_general_ci'; // latin1_swedish_ci, utf8_general_ci. Can't be static as it may be forced with a dynamic value
//! Version min database //! Version min database
static $versionmin=array(3,0,0); static $versionmin=array(3,0,0);
//! Resultset of last request //! Resultset of last query
private $_results; private $_results;
//! 1 if connected, 0 else
var $connected;
//! 1 if database selected, 0 else
var $database_selected;
//! Database name selected
var $database_name;
//! Nom user base
var $database_user;
//! >=1 if a transaction is opened, 0 otherwise
var $transaction_opened;
//! Last executed request
var $lastquery;
//! Last failed executed request
var $lastqueryerror;
//! Message erreur mysql
var $lasterror;
//! Message erreur mysql
var $lasterrno;
var $ok;
var $error;
/** /**
* Constructor. * Constructor.
@ -351,15 +323,6 @@ class DoliDBSqlite extends DoliDB
return $this->db; return $this->db;
} }
/**
* Return label of manager
*
* @return string Label
*/
function getLabel()
{
return $this->label;
}
/** /**
* Return version of database server * Return version of database server
@ -373,16 +336,6 @@ class DoliDBSqlite extends DoliDB
return $row[0]; return $row[0];
} }
/**
* Return version of database server into an array
*
* @return array Version array
*/
function getVersionArray()
{
return explode('.',$this->getVersion());
}
/** /**
* Return version of database client driver * Return version of database client driver
* *
@ -415,33 +368,6 @@ class DoliDBSqlite extends DoliDB
return false; return false;
} }
/**
* Start transaction
*
* @return int 1 if transaction successfuly opened or already opened, 0 if error
*/
function begin()
{
if (! $this->transaction_opened)
{
$ret=$this->query("BEGIN");
if ($ret)
{
$this->transaction_opened++;
dol_syslog("BEGIN Transaction",LOG_DEBUG);
dol_syslog('',0,1);
}
return $ret;
}
else
{
$this->transaction_opened++;
dol_syslog('',0,1);
return 1;
}
}
/** /**
* Validate a database transaction * Validate a database transaction
* *
@ -662,90 +588,6 @@ class DoliDBSqlite extends DoliDB
return $this->db->quote($stringtoencode); return $this->db->quote($stringtoencode);
} }
/**
* Convert (by PHP) a GM Timestamp date into a PHP server TZ to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica
*
* @param string $param Date TMS to convert
* @return string Date in a string YYYYMMDDHHMMSS
*/
function idate($param)
{
return dol_print_date($param,"%Y%m%d%H%M%S");
}
/**
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
* 19700101020000 -> 3600 with TZ+1 and gmt=0
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
*
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @return date Date TMS
*/
function jdate($string, $gm=false)
{
$string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000';
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
return $date;
}
/**
* Format a SQL IF
*
* @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
* @param string $resok resultat si test egal
* @param string $resko resultat si test non egal
* @return string SQL string
*/
function ifsql($test,$resok,$resko)
{
return 'IF('.$test.','.$resok.','.$resko.')';
}
/**
* Renvoie la derniere requete soumise par la methode query()
*
* @return lastquery
*/
function lastquery()
{
return $this->lastquery;
}
/**
* Return last query in error
*
* @return string lastqueryerror
*/
function lastqueryerror()
{
return $this->lastqueryerror;
}
/**
* Return last error label
*
* @return string lasterror
*/
function lasterror()
{
return $this->lasterror;
}
/**
* Return last error code
*
* @return string lasterrno
*/
function lasterrno()
{
return $this->lasterrno;
}
/** /**
* Renvoie le code erreur generique de l'operation precedente. * Renvoie le code erreur generique de l'operation precedente.
* *

View File

@ -580,6 +580,7 @@ class Expedition extends CommonObject
//var_dump($this->lines[$i]); //var_dump($this->lines[$i]);
$mouvS = new MouvementStock($this->db); $mouvS = new MouvementStock($this->db);
$mouvS->origin = &$this;
// We decrement stock of product (and sub-products) // We decrement stock of product (and sub-products)
// We use warehouse selected for each line // We use warehouse selected for each line
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref)); $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref));
@ -902,6 +903,7 @@ class Expedition extends CommonObject
//var_dump($this->lines[$i]); //var_dump($this->lines[$i]);
$mouvS = new MouvementStock($this->db); $mouvS = new MouvementStock($this->db);
$mouvS->origin = &$this;
// We decrement stock of product (and sub-products) // We decrement stock of product (and sub-products)
// We use warehouse selected for each line // We use warehouse selected for each line
$result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentDeletedInDolibarr",$this->ref)); $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentDeletedInDolibarr",$this->ref));

View File

@ -635,6 +635,7 @@ class CommandeFournisseur extends CommonOrder
if ($this->lines[$i]->fk_product > 0) if ($this->lines[$i]->fk_product > 0)
{ {
$mouvP = new MouvementStock($this->db); $mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
// We decrement stock of product (and sub-products) // We decrement stock of product (and sub-products)
$up_ht_disc=$this->lines[$i]->subprice; $up_ht_disc=$this->lines[$i]->subprice;
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'); 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');
@ -1288,6 +1289,7 @@ class CommandeFournisseur extends CommonOrder
if ($product > 0) if ($product > 0)
{ {
// $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on) // $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on)
$mouv->origin = &$this;
$result=$mouv->reception($user, $product, $entrepot, $qty, $price, $comment); $result=$mouv->reception($user, $product, $entrepot, $qty, $price, $comment);
if ($result < 0) if ($result < 0)
{ {

View File

@ -906,6 +906,7 @@ class FactureFournisseur extends CommonInvoice
if ($this->lines[$i]->fk_product > 0) if ($this->lines[$i]->fk_product > 0)
{ {
$mouvP = new MouvementStock($this->db); $mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
// We increase stock for product // We increase stock for product
$up_ht_disc=$this->lines[$i]->pu_ht; $up_ht_disc=$this->lines[$i]->pu_ht;
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'); 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');

View File

@ -74,7 +74,7 @@ $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db-
if ($db->ok == 1) if ($db->ok == 1)
{ {
print '<tr><td>'.$langs->trans("DolibarrAdminLogin").' :</td><td>'; print '<tr><td>'.$langs->trans("DolibarrAdminLogin").' :</td><td>';
print '<input name="login" 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:'')).'"></td></tr>';
print '<tr><td>'.$langs->trans("Password").' :</td><td>'; print '<tr><td>'.$langs->trans("Password").' :</td><td>';
print '<input type="password" name="pass"></td></tr>'; print '<input type="password" name="pass"></td></tr>';
print '<tr><td>'.$langs->trans("PasswordAgain").' :</td><td>'; print '<tr><td>'.$langs->trans("PasswordAgain").' :</td><td>';

View File

@ -1061,3 +1061,7 @@ CREATE TABLE llx_payment_salary (
fk_user_creat integer, fk_user_creat integer,
fk_user_modif integer fk_user_modif integer
)ENGINE=innodb; )ENGINE=innodb;
--New 1074 : Stock mouvement link to origin
ALTER TABLE llx_stock_mouvement ADD fk_origin INT NOT NULL ;
ALTER TABLE llx_stock_mouvement ADD origintype VARCHAR( 32 ) NOT NULL ;

View File

@ -28,6 +28,7 @@ InvoiceReplacementDesc=<b>Replacement invoice</b> is used to cancel and replace
InvoiceAvoir=Credit note InvoiceAvoir=Credit note
InvoiceAvoirAsk=Credit note to correct invoice InvoiceAvoirAsk=Credit note to correct invoice
InvoiceAvoirDesc=The <b>credit note</b> is a negative invoice used to solve fact that an invoice has an amount that differs than amount really paid (because customer paid too much by error, or will not paid completely since he returned some products for example). InvoiceAvoirDesc=The <b>credit note</b> is a negative invoice used to solve fact that an invoice has an amount that differs than amount really paid (because customer paid too much by error, or will not paid completely since he returned some products for example).
invoiceAvoirWithLines=Create Credit Note with lines from the origin invoice
ReplaceInvoice=Replace invoice %s ReplaceInvoice=Replace invoice %s
ReplacementInvoice=Replacement invoice ReplacementInvoice=Replacement invoice
ReplacedByInvoice=Replaced by invoice %s ReplacedByInvoice=Replaced by invoice %s

View File

@ -28,6 +28,7 @@ InvoiceReplacementDesc=La <b>facture de remplacement</b> sert à annuler et remp
InvoiceAvoir=Facture avoir InvoiceAvoir=Facture avoir
InvoiceAvoirAsk=Facture avoir pour correction de la facture InvoiceAvoirAsk=Facture avoir pour correction de la facture
InvoiceAvoirDesc=La <b>facture d'avoir</b> est une facture négative destinée à compenser un montant de facture qui diffère du montant réellement versé (suite à un trop versé par le client par erreur ou un manque non versé par le client suite à un retour produit par exemple). InvoiceAvoirDesc=La <b>facture d'avoir</b> est une facture négative destinée à compenser un montant de facture qui diffère du montant réellement versé (suite à un trop versé par le client par erreur ou un manque non versé par le client suite à un retour produit par exemple).
invoiceAvoirWithLines=Créer la facture d'avoir avec les lignes de la facture d'origine
ReplaceInvoice=Remplace la facture %s ReplaceInvoice=Remplace la facture %s
ReplacementInvoice=Remplacement facture ReplacementInvoice=Remplacement facture
ReplacedByInvoice=Remplacée par la facture %s ReplacedByInvoice=Remplacée par la facture %s

View File

@ -301,7 +301,7 @@ DemandReasonTypeSRC_CAMP_EMAIL=Campagne EMailing
DemandReasonTypeSRC_CAMP_PHO=Campagne Téléphonique DemandReasonTypeSRC_CAMP_PHO=Campagne Téléphonique
DemandReasonTypeSRC_CAMP_FAX=Campagne Fax DemandReasonTypeSRC_CAMP_FAX=Campagne Fax
DemandReasonTypeSRC_COMM=Contact commercial DemandReasonTypeSRC_COMM=Contact commercial
DemandReasonTypeSRC_SHOP=Contact en magazin DemandReasonTypeSRC_SHOP=Contact en magasin
DemandReasonTypeSRC_WOM=Bouche à oreille DemandReasonTypeSRC_WOM=Bouche à oreille
DemandReasonTypeSRC_PARTNER=Partenaire DemandReasonTypeSRC_PARTNER=Partenaire
DemandReasonTypeSRC_EMPLOYEE=Employé DemandReasonTypeSRC_EMPLOYEE=Employé

View File

@ -94,12 +94,23 @@ class MouvementStock
if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after
{ {
if(!empty($this->origin)) {
$origintype = $this->origin->element;
$fk_origin = $this->origin->id;
} else {
$origintype = '';
$fk_origin = 0;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement";
$sql.= " (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author, label, price)"; $sql.= " (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author, label, price, fk_origin, origintype)";
$sql.= " VALUES ('".$this->db->idate($now)."', ".$fk_product.", ".$entrepot_id.", ".$qty.", ".$type.","; $sql.= " VALUES ('".$this->db->idate($now)."', ".$fk_product.", ".$entrepot_id.", ".$qty.", ".$type.",";
$sql.= " ".$user->id.","; $sql.= " ".$user->id.",";
$sql.= " '".$this->db->escape($label)."',"; $sql.= " '".$this->db->escape($label)."',";
$sql.= " '".price2num($price)."')"; $sql.= " '".price2num($price)."',";
$sql.= " '".$fk_origin."',";
$sql.= " '".$origintype."'";
$sql.= ")";
dol_syslog(get_class($this)."::_create sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::_create sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -469,5 +480,36 @@ class MouvementStock
} }
function get_origin($fk_origin, $origintype) {
switch ($origintype) {
case 'commande':
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$origin = new Commande($this->db);
break;
case 'shipping':
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
$origin = new Expedition($this->db);
break;
case 'facture':
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$origin = new Facture($this->db);
break;
case 'order_supplier':
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$origin = new CommandeFournisseur($this->db);
break;
case 'invoice_supplier':
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$origin = new FactureFournisseur($this->db);
break;
default:
return '';
break;
}
$origin->fetch($fk_origin);
return $origin->getNomUrl(1);
}
} }
?> ?>

View File

@ -120,7 +120,7 @@ $formproduct=new FormProduct($db);
$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type,"; $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type,";
$sql.= " e.label as stock, e.rowid as entrepot_id,"; $sql.= " e.label as stock, e.rowid as entrepot_id,";
$sql.= " m.rowid as mid, m.value, m.datem, m.fk_user_author, m.label,"; $sql.= " m.rowid as mid, m.value, m.datem, m.fk_user_author, m.label, m.fk_origin, m.origintype,";
$sql.= " u.login"; $sql.= " u.login";
$sql.= " FROM (".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " FROM (".MAIN_DB_PREFIX."entrepot as e,";
$sql.= " ".MAIN_DB_PREFIX."product as p,"; $sql.= " ".MAIN_DB_PREFIX."product as p,";
@ -418,6 +418,7 @@ if ($resql)
//print_liste_field_titre($langs->trans("Id"),$_SERVER["PHP_SELF"], "m.rowid","",$param,"",$sortfield,$sortorder); //print_liste_field_titre($langs->trans("Id"),$_SERVER["PHP_SELF"], "m.rowid","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"], "m.datem","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"], "m.datem","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("LabelMovement"),$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("LabelMovement"),$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ProductRef"),$_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("ProductRef"),$_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ProductLabel"),$_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("ProductLabel"),$_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Warehouse"),$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible print_liste_field_titre($langs->trans("Warehouse"),$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible
@ -440,6 +441,10 @@ if ($resql)
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" size="10" name="search_movement" value="'.$search_movement.'">'; print '<input class="flat" type="text" size="10" name="search_movement" value="'.$search_movement.'">';
print '</td>'; print '</td>';
// Origin of movement
print '<td class="liste_titre" align="left">';
print '&nbsp; ';
print '</td>';
// Product Ref // Product Ref
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" size="6" name="search_product_ref" value="'.($idproduct?$product->ref:$search_product_ref).'">'; print '<input class="flat" type="text" size="6" name="search_product_ref" value="'.($idproduct?$product->ref:$search_product_ref).'">';
@ -470,6 +475,11 @@ if ($resql)
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$arrayofuniqueproduct[$objp->rowid]=$objp->produit; $arrayofuniqueproduct[$objp->rowid]=$objp->produit;
if(!empty($objp->fk_origin)) {
$origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
} else {
$origin = '';
}
$var=!$var; $var=!$var;
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
@ -479,6 +489,8 @@ if ($resql)
print '<td>'.dol_print_date($db->jdate($objp->datem),'dayhour').'</td>'; print '<td>'.dol_print_date($db->jdate($objp->datem),'dayhour').'</td>';
// Label of movement // Label of movement
print '<td>'.$objp->label.'</td>'; print '<td>'.$objp->label.'</td>';
// Origin of movement
print '<td>'.$origin.'</td>';
// Product ref // Product ref
print '<td>'; print '<td>';
$productstatic->id=$objp->rowid; $productstatic->id=$objp->rowid;