Merge remote-tracking branch 'origin/3.5' into develop
This commit is contained in:
commit
b2f6498236
@ -997,7 +997,7 @@ function dol_getdate($timestamp,$fast=false)
|
||||
* @param int $month Month (1 to 12)
|
||||
* @param int $day Day (1 to 31)
|
||||
* @param int $year Year
|
||||
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
|
||||
* @param int $gm true or 1=Input informations are GMT values, false or 0 or 'server' = local to server TZ, 'user' = local to user TZ
|
||||
* @param int $check 0=No check on parameters (Can use day 32, etc...)
|
||||
* @return int Date as a timestamp, '' if error
|
||||
* @see dol_print_date, dol_stringtotime, dol_getdate
|
||||
@ -1025,7 +1025,23 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
|
||||
|
||||
if (method_exists('DateTime','getTimestamp'))
|
||||
{
|
||||
if (empty($gm)) $localtz = new DateTimeZone(date_default_timezone_get());
|
||||
if (empty($gm) || $gm === 'server')
|
||||
{
|
||||
// If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
|
||||
// In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore.
|
||||
if (! empty($conf->global->MAIN_SERVER_TZ))
|
||||
{
|
||||
if ($conf->global->MAIN_SERVER_TZ != 'auto') $default_timezone=$conf->global->MAIN_SERVER_TZ;
|
||||
else $default_timezone=@date_default_timezone_get();
|
||||
}
|
||||
else $default_timezone=@date_default_timezone_get();
|
||||
$localtz = new DateTimeZone($default_timezone);
|
||||
}
|
||||
else if ($gm === 'user')
|
||||
{
|
||||
$default_timezone=(empty($_SESSION["dol_tz_string"])?'UTC':$_SESSION["dol_tz_string"]);
|
||||
$localtz = new DateTimeZone($default_timezone);
|
||||
}
|
||||
else $localtz = new DateTimeZone('UTC');
|
||||
$dt = new DateTime(null,$localtz);
|
||||
$dt->setDate($year,$month,$day);
|
||||
|
||||
@ -461,45 +461,46 @@ class ImportCsv extends ModeleImports
|
||||
{
|
||||
if (empty($newval)) $newval='0';
|
||||
}
|
||||
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifnull')
|
||||
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto')
|
||||
{
|
||||
if (empty($newval) || strtolower($newval) == 'auto')
|
||||
if (strtolower($newval) == 'auto')
|
||||
{
|
||||
$this->thirpartyobject->get_codeclient(0,0);
|
||||
$newval=$this->thirpartyobject->code_client;
|
||||
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
|
||||
//print 'code_client='.$newval;
|
||||
}
|
||||
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
|
||||
}
|
||||
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsuppliercodeifnull')
|
||||
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsuppliercodeifauto')
|
||||
{
|
||||
if (empty($newval) || strtolower($newval) == 'auto')
|
||||
if (strtolower($newval) == 'auto')
|
||||
{
|
||||
$newval=$this->thirpartyobject->get_codefournisseur(0,1);
|
||||
$newval=$this->thirpartyobject->code_fournisseur;
|
||||
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
|
||||
//print 'code_fournisseur='.$newval;
|
||||
}
|
||||
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
|
||||
}
|
||||
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomeraccountancycodeifnull')
|
||||
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomeraccountancycodeifauto')
|
||||
{
|
||||
if (empty($newval) || strtolower($newval) == 'auto')
|
||||
if (strtolower($newval) == 'auto')
|
||||
{
|
||||
$this->thirpartyobject->get_codecompta('customer');
|
||||
$newval=$this->thirpartyobject->code_compta;
|
||||
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
|
||||
//print 'code_compta='.$newval;
|
||||
}
|
||||
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
|
||||
}
|
||||
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsupplieraccountancycodeifnull')
|
||||
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsupplieraccountancycodeifauto')
|
||||
{
|
||||
if (empty($newval) || strtolower($newval) == 'auto')
|
||||
if (strtolower($newval) == 'auto')
|
||||
{
|
||||
$this->thirpartyobject->get_codecompta('supplier');
|
||||
$newval=$this->thirpartyobject->code_compta_fournisseur;
|
||||
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
|
||||
//print 'code_compta_fournisseur='.$newval;
|
||||
}
|
||||
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
|
||||
}
|
||||
|
||||
//print 'Val to use as insert is '.$newval.'<br>';
|
||||
@ -670,4 +671,4 @@ function cleansep($value)
|
||||
};
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@ -401,14 +401,14 @@ class modSociete extends DolibarrModules
|
||||
's.fk_typent'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ctypent.class.php','class'=>'Ctypent','method'=>'fetch','dict'=>'DictionaryCompanyType'),
|
||||
's.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cpays.class.php','class'=>'Cpays','method'=>'fetch','dict'=>'DictionaryCountry'),
|
||||
's.fk_stcomm'=>array('rule'=>'zeroifnull'),
|
||||
's.code_client'=>array('rule'=>'getcustomercodeifnull'),
|
||||
's.code_fournisseur'=>array('rule'=>'getsuppliercodeifnull'),
|
||||
's.code_compta'=>array('rule'=>'getcustomeraccountancycodeifnull'),
|
||||
's.code_compta_fournisseur'=>array('rule'=>'getsupplieraccountancycodeifnull')
|
||||
's.code_client'=>array('rule'=>'getcustomercodeifauto'),
|
||||
's.code_fournisseur'=>array('rule'=>'getsuppliercodeifauto'),
|
||||
's.code_compta'=>array('rule'=>'getcustomeraccountancycodeifauto'),
|
||||
's.code_compta_fournisseur'=>array('rule'=>'getsupplieraccountancycodeifauto')
|
||||
);
|
||||
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
|
||||
$this->import_regex_array[$r]=array('s.status'=>'^[0|1]','s.client'=>'^[0|1|2|3]','s.fournisseur'=>'^[0|1]','s.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
|
||||
$this->import_examplevalues_array[$r]=array('s.nom'=>"MyBigCompany",'s.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'s.code_client'=>"CU01-0001 or auto",'s.code_fournisseur'=>"SU01-0001 or auto",'s.address'=>"61 jump street",'s.zip'=>"123456",'s.town'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.phone'=>"0101010101",'s.fax'=>"0101010102",'s.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note_private'=>"This is an example of private note for record",'s.note_public'=>"This is an example of public note for record",'s.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789');
|
||||
$this->import_examplevalues_array[$r]=array('s.nom'=>"MyBigCompany",'s.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'s.code_client'=>"CU01-0001 or empty or 'auto'",'s.code_fournisseur'=>"SU01-0001 or empty or 'auto'",'s.address'=>"61 jump street",'s.zip'=>"123456",'s.town'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.phone'=>"0101010101",'s.fax'=>"0101010102",'s.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note_private'=>"This is an example of private note for record",'s.note_public'=>"This is an example of public note for record",'s.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789');
|
||||
|
||||
// Import list of contact and attributes
|
||||
$r++;
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
"Name* (s.nom)";"Status (s.status)";"Customer* (s.client)";"Supplier* (s.fournisseur)";"DateCreation (s.datec)";"CustomerCode (s.code_client)";"SupplierCode (s.code_fournisseur)";"Address (s.address)";"Zip (s.cp)";"Town (s.ville)";"Phone (s.tel)";"Fax (s.fax)";"Url (s.url)";"Email (s.email)";"IdProf1 (s.siret)";"IdProf2 (s.siren)";"IdProf3 (s.ape)";"IdProf4 (s.idprof4)";"VATIntraShort (s.tva_intra)";"Capital (s.capital)";"Note (s.note)";"ThirdPartyType (s.fk_typent)";"Effectif (s.fk_effectif)";"JuridicalStatus (s.fk_forme_juridique)";"ProspectLevel (s.fk_prospectlevel)";"ProspectStatus (s.fk_stcomm)";"DefaultLanguage (s.default_lang)";"BarCode (s.barcode)"
|
||||
"MyBigCompanyImport1";1;3;1;01/01/00;"CU01-0001";"SU01-0001";"61 jump street";123456;"Big town";101010101;101010102;"http://mycompany.com";"test@mycompany.com";;;;;"FR0123456789";10000;"This is an example of note for record";2;3;1;"PL_MEDIUM";1;"en_US";123456789
|
||||
"MyBigCompanyImport1";1;3;1;01/01/00;"CU01-0001";"SU01-0001";"61 jump street";123456;"Big town";101010101;101010111;"http://mycompany.com";"test@mycompany.com";;;;;"FR0123456781";10000;"This is an example of note for record 1";2;3;1;"PL_MEDIUM";1;"en_US";123456781
|
||||
"MyBigCompanyImport2";1;3;1;01/01/00;"auto";;"62 jump street";123456;"Big town";101010102;101010112;"http://mycompany2.com";"test@mycompany2.com";;;;;"FR0123456782";10000;"This is an example of note for record 2";2;3;1;"PL_MEDIUM";1;"en_US";auto
|
||||
|
||||
|
@ -162,7 +162,7 @@ class FilesLibTest extends PHPUnit_Framework_TestCase
|
||||
$file=dirname(__FILE__).'/Example_import_company_1.csv';
|
||||
$result=dol_count_nb_of_line($file);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(2,$result);
|
||||
$this->assertEquals(3,$result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -125,7 +125,10 @@ class ImportTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$file=dirname(__FILE__).'/Example_import_company_1.csv';
|
||||
|
||||
//if (! preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i','2012-03-23')) print 'eeeeeeeeeeee';
|
||||
// TODO
|
||||
// Run import on file and check the record with field "auto" are filled
|
||||
// according to option
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user