Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.5' into develop
Browse files Browse the repository at this point in the history
Conflicts:
	htdocs/core/modules/propale/mod_propale_marbre.php
  • Loading branch information
eldy committed May 21, 2014
2 parents b396272 + 4a7e9e4 commit 94335b1
Show file tree
Hide file tree
Showing 21 changed files with 111 additions and 75 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Expand Up @@ -130,6 +130,9 @@ Fix: [ bug #1367 ] "Show invoice" link after a POS sell throws an error.
Fix: TCPDF error file not found in member card generation.
Fix: [ bug #1380 ] Customer invoices are not grouped in company results report.
Fix: [ bug #1393 ] PHP Warning when creating a supplier invoice.
Fix: [ bug #1399 ] [pgsql] Silent warning when setting a propal as "facturée" in propal.php
Fix: When number reach 9999 with default numbering module, next number
will be 10000 instead of 0000 and error.

***** ChangeLog for 3.5.2 compared to 3.5.1 *****
Fix: Can't add user for a task.
Expand Down
41 changes: 20 additions & 21 deletions htdocs/admin/boxes.php
Expand Up @@ -57,7 +57,7 @@

$db->begin();

// Initialize distinctfkuser with all already existing values of fk_user (user that use a personalized view of boxes for pos)
// Initialize distinct fkuser with all already existing values of fk_user (user that use a personalized view of boxes for page "pos")
$distinctfkuser=array();
if (! $error)
{
Expand Down Expand Up @@ -85,14 +85,31 @@
}
}

$distinctfkuser['0']='0'; // Add entry for fk_user = 0. We must use string as key and val

foreach($distinctfkuser as $fk_user)
{
if (! $error && $fk_user != 0) // We will add fk_user = 0 later.
if (! $error && $fk_user != '')
{
$nbboxonleft=$nbboxonright=0;
$sql = "SELECT box_order FROM ".MAIN_DB_PREFIX."boxes WHERE position = ".GETPOST("pos","alpha")." AND fk_user = ".$fk_user." AND entity = ".$conf->entity;
dol_syslog("boxes.php activate box sql=".$sql);
$resql = $db->query($sql);
if ($resql)
{
while($obj = $db->fetch_object($resql))
{
$boxorder=$obj->box_order;
if (preg_match('/A/',$boxorder)) $nbboxonleft++;
if (preg_match('/B/',$boxorder)) $nbboxonright++;
}
}
else dol_print_error($db);

$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
$sql.= "box_id, position, box_order, fk_user, entity";
$sql.= ") values (";
$sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", 'A01', ".$fk_user.", ".$conf->entity;
$sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity;
$sql.= ")";

dol_syslog("boxes.php activate box sql=".$sql);
Expand All @@ -105,24 +122,6 @@
}
}

// If value 0 was not included, we add it.
if (! $error)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
$sql.= "box_id, position, box_order, fk_user, entity";
$sql.= ") values (";
$sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", 'A01', 0, ".$conf->entity;
$sql.= ")";

dol_syslog("boxes.php activate box sql=".$sql);
$resql = $db->query($sql);
if (! $resql)
{
$errmesg=$db->lasterror();
$error++;
}
}

if (! $error)
{
header("Location: boxes.php");
Expand Down
4 changes: 1 addition & 3 deletions htdocs/admin/dict.php
Expand Up @@ -532,9 +532,7 @@
$result = $db->query($sql);
if ($result) // Add is ok
{
//$oldid=$id;
//$_POST=array('id'=>$oldid); // Clean $_POST array, we keep only
//$_GET["id"]=$_POST["id"]; // Force affichage dictionnaire en cours d'edition
$_POST=array('id'=>$id); // Clean $_POST array, we keep only
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal/class/propal.class.php
Expand Up @@ -1724,7 +1724,7 @@ function cloture($user, $statut, $note)
$this->db->begin();

$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($note)."', date_cloture=".$this->db->idate($now).", fk_user_cloture=".$user->id;
$sql.= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id;
$sql.= " WHERE rowid = ".$this->id;

$resql=$this->db->query($sql);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/compta/prelevement/fiche.php
Expand Up @@ -133,7 +133,7 @@
$bon = new BonPrelevement($db,"");
$form = new Form($db);

llxHeader('',$langs->trans("WithdrawalsReceipts")); i
llxHeader('',$langs->trans("WithdrawalsReceipts"));


if ($id > 0)
Expand All @@ -151,7 +151,7 @@
/*if ($action == 'credite')
{
print $form->formconfirm("fiche.php?id=".$bon->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1);
}*/

print '<table class="border" width="100%">';
Expand Down
3 changes: 2 additions & 1 deletion htdocs/core/db/pgsql.class.php
Expand Up @@ -196,7 +196,8 @@ static function convertSQLFromMysql($line,$type='auto',$unescapeslashquot=0)

// nuke unsigned
$line=preg_replace('/(int\w+|smallint)\s+unsigned/i','\\1',$line);

$line=preg_replace('/as signed/i','as integer',$line);

// blob -> text
$line=preg_replace('/\w*blob/i','text',$line);

Expand Down
9 changes: 8 additions & 1 deletion htdocs/core/lib/functions2.lib.php
Expand Up @@ -536,7 +536,7 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti
* @param Societe $objsoc The company that own the object we need a counter for
* @param string $date Date to use for the {y},{m},{d} tags.
* @param string $mode 'next' for next value or 'last' for last value
* @return string New value
* @return string New value (numeric) or error message
*/
function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next')
{
Expand Down Expand Up @@ -798,6 +798,12 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
{
$counter++;

// If value for $counter has a length higher than $maskcounter chars
if ($counter >= pow(10, dol_strlen($maskcounter)))
{
$counter='ErrorMaxNumberReachForThisMask';
}

if (! empty($maskrefclient_maskcounter))
{
//print "maskrefclient_maskcounter=".$maskrefclient_maskcounter." maskwithnocode=".$maskwithnocode." maskrefclient=".$maskrefclient."\n<br>";
Expand Down Expand Up @@ -839,6 +845,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
$maskrefclient_counter = $maskrefclient_obj->val;
}
else dol_print_error($db);

if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) $maskrefclient_counter=$maskrefclient_maskoffset;
$maskrefclient_counter++;
}
Expand Down
8 changes: 5 additions & 3 deletions htdocs/core/modules/commande/mod_commande_marbre.php
Expand Up @@ -71,7 +71,7 @@ function canBeActivated()
$coyymm=''; $max='';

$posindice=8;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand Down Expand Up @@ -105,7 +105,7 @@ function getNextValue($objsoc,$object)

// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE ref like '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand All @@ -126,7 +126,9 @@ function getNextValue($objsoc,$object)
//$date=time();
$date=$object->date;
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);

if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s",$max+1);

dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
Expand Down
8 changes: 5 additions & 3 deletions htdocs/core/modules/contract/mod_contract_serpis.php
Expand Up @@ -69,7 +69,7 @@ function canBeActivated()
$coyymm=''; $max='';

$posindice=8;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand Down Expand Up @@ -102,7 +102,7 @@ function getNextValue($objsoc,$contract)
global $db,$conf;

$posindice=8;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat";
$sql.= " WHERE ref like '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand All @@ -122,7 +122,9 @@ function getNextValue($objsoc,$contract)

$date=$contract->date_contrat;
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);

if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s",$max+1);

dol_syslog("mod_contract_serpis::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
Expand Down
8 changes: 5 additions & 3 deletions htdocs/core/modules/expedition/mod_expedition_safor.php
Expand Up @@ -69,7 +69,7 @@ function canBeActivated()
$coyymm=''; $max='';

$posindice=8;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand Down Expand Up @@ -102,7 +102,7 @@ function getNextValue($objsoc,$shipment)
global $db,$conf;

$posindice=8;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
$sql.= " WHERE ref like '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand All @@ -122,7 +122,9 @@ function getNextValue($objsoc,$shipment)

$date=time();
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);

if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s",$max+1);

dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
Expand Down
11 changes: 7 additions & 4 deletions htdocs/core/modules/facture/mod_facture_mars.php
Expand Up @@ -75,7 +75,7 @@ function canBeActivated()
$fayymm=''; $max='';

$posindice=8;
$sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$this->prefixinvoice."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand Down Expand Up @@ -138,7 +138,7 @@ function getNextValue($objsoc,$facture,$mode='next')

// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand All @@ -159,7 +159,8 @@ function getNextValue($objsoc,$facture,$mode='next')

if ($mode == 'last')
{
$num = sprintf("%04s",$max);
if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s",$max);

$ref='';
$sql = "SELECT facnumber as ref";
Expand All @@ -182,7 +183,9 @@ function getNextValue($objsoc,$facture,$mode='next')
{
$date=$facture->date; // This is invoice date (not creation date)
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);

if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s",$max+1);

dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
return $prefix.$yymm."-".$num;
Expand Down
15 changes: 9 additions & 6 deletions htdocs/core/modules/facture/mod_facture_terre.php
Expand Up @@ -73,7 +73,7 @@ function canBeActivated()
$fayymm=''; $max='';

$posindice=8;
$sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$this->prefixinvoice."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand All @@ -95,7 +95,7 @@ function canBeActivated()
$fayymm='';

$posindice=8;
$sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$this->prefixcreditnote."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand All @@ -116,7 +116,7 @@ function canBeActivated()
$fayymm='';

$posindice=8;
$sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$this->prefixdeposit."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand Down Expand Up @@ -154,7 +154,7 @@ function getNextValue($objsoc,$facture,$mode='next')

// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand All @@ -175,7 +175,8 @@ function getNextValue($objsoc,$facture,$mode='next')

if ($mode == 'last')
{
$num = sprintf("%04s",$max);
if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s",$max);

$ref='';
$sql = "SELECT facnumber as ref";
Expand All @@ -198,7 +199,9 @@ function getNextValue($objsoc,$facture,$mode='next')
{
$date=$facture->date; // This is invoice date (not creation date)
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);

if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s",$max+1);

dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
return $prefix.$yymm."-".$num;
Expand Down
8 changes: 5 additions & 3 deletions htdocs/core/modules/fichinter/mod_pacific.php
Expand Up @@ -72,7 +72,7 @@ function canBeActivated()
$fayymm=''; $max='';

$posindice=8;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE ref like '".$this->prefix."____-%'";
$sql.= " WHERE entity = ".$conf->entity;
Expand Down Expand Up @@ -108,7 +108,7 @@ function getNextValue($objsoc=0,$object='')

// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand All @@ -124,7 +124,9 @@ function getNextValue($objsoc=0,$object='')
//$date=time();
$date=$object->datec;
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);

if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s",$max+1);

return $this->prefix.$yymm."-".$num;
}
Expand Down
8 changes: 5 additions & 3 deletions htdocs/core/modules/livraison/mod_livraison_jade.php
Expand Up @@ -78,7 +78,7 @@ function canBeActivated()
$fayymm=''; $max='';

$posindice=8;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."livraison";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand Down Expand Up @@ -112,7 +112,7 @@ function getNextValue($objsoc,$object)

// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."livraison";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
Expand All @@ -134,7 +134,9 @@ function getNextValue($objsoc,$object)
$date=$object->date_delivery;
if (empty($date)) $date=dol_now();
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);

if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s",$max+1);

dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
Expand Down

0 comments on commit 94335b1

Please sign in to comment.