Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.4' into 3.4_backported
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 21, 2014
2 parents 8a54230 + b8aee5f commit f373567
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
21 changes: 14 additions & 7 deletions htdocs/core/lib/functions2.lib.php
Expand Up @@ -535,9 +535,9 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m

// For debugging
//include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php');
//$mask='{yyyy}-{0000}';
//$mask='FA{yy}{mm}-{0000@99}';
//$date=dol_mktime(12, 0, 0, 1, 1, 1900);
//$date=dol_stringtotime('20121001');
//$date=dol_stringtotime('20130101');

// Extract value for mask counter, mask raz and mask offset
if (! preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$mask,$reg)) return 'ErrorBadMask';
Expand Down Expand Up @@ -612,24 +612,31 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
if ($maskraz > 0) // A reset is required
{
if ($maskraz == 99) {
$maskraz = date('m');
$maskraz = date('m',$date);
$resetEveryMonth = true;
}
if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth';

// Define posy, posm and reg
if ($maskraz > 1)
if ($maskraz >= 1 && $resetEveryMonth)
{
if (! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode)
&& ! preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask';
if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; }
elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; }
if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit';
}
else
elseif ($maskraz > 1)
{
if (! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode)) return 'ErrorCantUseRazIfNoYearInMask';
if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; }
if (! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode)
&& ! preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask';
if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; }
elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; }
if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit';

} else {
if (! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode)) return 'ErrorCantUseRazIfNoYearInMask';
if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; }
}
//print "x".$maskwithonlyymcode." ".$maskraz." ".$posy." ".$posm;
//var_dump($reg);
Expand Down
12 changes: 6 additions & 6 deletions htdocs/core/modules/modBarcode.class.php
Expand Up @@ -111,12 +111,12 @@ function init($options='')
$this->remove($options);

$sql = array(
array('sql'=>"INSERT INTO llx_c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO llx_c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO llx_c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO llx_c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO llx_c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO llx_c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1)
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1)
);

return $this->_init($sql, $options);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/class/product.class.php
Expand Up @@ -36,7 +36,7 @@ class Product extends CommonObject
public $element='product';
public $table_element='product';
public $fk_element='fk_product';
protected $childtables=array('propaldet','commandedet','facturedet','contratdet'); // To test if we can delete object
protected $childtables=array('propaldet','commandedet','facturedet','contratdet','facture_fourn_det','commande_fournisseurdet'); // To test if we can delete object
protected $isnolinkedbythird = 1; // No field fk_soc
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe

Expand Down

0 comments on commit f373567

Please sign in to comment.