New: dol_strintotime accept format YYYY-MM-DD HH:MM:SS
Fix: create member was missing field import_key New: Uniformize code
This commit is contained in:
parent
c590f6482e
commit
c92aa1f6aa
@ -266,6 +266,9 @@ class Adherent extends CommonObject
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
// Clean parameters
|
||||
$this->import_key = trim($this->import_key);
|
||||
|
||||
// Check parameters
|
||||
if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email))
|
||||
{
|
||||
@ -287,7 +290,7 @@ class Adherent extends CommonObject
|
||||
|
||||
// Insert member
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent";
|
||||
$sql.= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity)";
|
||||
$sql.= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)";
|
||||
$sql.= " VALUES (";
|
||||
$sql.= " '".$this->db->idate($this->datec)."'";
|
||||
$sql.= ", ".($this->login?"'".$this->db->escape($this->login)."'":"null");
|
||||
@ -295,6 +298,7 @@ class Adherent extends CommonObject
|
||||
$sql.= ", null, null, '".$this->morphy."'";
|
||||
$sql.= ", '".$this->typeid."'";
|
||||
$sql.= ", ".$conf->entity;
|
||||
$sql.= ", ".(! empty($this->import_key) ? "'".$this->import_key."'":"null");
|
||||
$sql.= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::create sql=".$sql);
|
||||
|
||||
@ -96,9 +96,9 @@ class Cotisation extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* Fonction qui permet de recuperer une cotisation
|
||||
* Method to load a subscription
|
||||
*
|
||||
* @param int $rowid Id cotisation
|
||||
* @param int $rowid Id subscription
|
||||
* @return int <0 if KO, =0 if not found, >0 if OK
|
||||
*/
|
||||
function fetch($rowid)
|
||||
@ -111,7 +111,7 @@ class Cotisation extends CommonObject
|
||||
$sql.=" FROM ".MAIN_DB_PREFIX."cotisation";
|
||||
$sql.=" WHERE rowid=".$rowid;
|
||||
|
||||
dol_syslog("Cotisation::fetch sql=".$sql);
|
||||
dol_syslog(get_class($this)."::fetch sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -166,7 +166,7 @@ class Cotisation extends CommonObject
|
||||
$sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null');
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog("Cotisation::update sql=".$sql);
|
||||
dol_syslog(get_class($this)."::update sql=".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -181,7 +181,7 @@ class Cotisation extends CommonObject
|
||||
{
|
||||
$this->db->rollback();
|
||||
$this->error=$this->db->error();
|
||||
dol_syslog("Cotisation::update ".$this->error, LOG_ERR);
|
||||
dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -205,7 +205,7 @@ class Cotisation extends CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."cotisation WHERE rowid = ".$this->id;
|
||||
dol_syslog("Cotisation::delete sql=".$sql);
|
||||
dol_syslog(get_class($this)."::delete sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
|
||||
@ -37,12 +37,12 @@ abstract class CommonObject
|
||||
public $errors;
|
||||
public $canvas; // Contains canvas name if it is
|
||||
|
||||
public $name;
|
||||
public $lastname;
|
||||
public $firstname;
|
||||
public $name;
|
||||
public $nom;
|
||||
public $civility_id;
|
||||
|
||||
public $import_key;
|
||||
|
||||
public $array_options=array();
|
||||
|
||||
public $linkedObjectsIds;
|
||||
|
||||
@ -205,9 +205,9 @@ function societe_admin_prepare_head($object)
|
||||
|
||||
|
||||
/**
|
||||
* Return country label, code or id from an id or a code
|
||||
* Return country label, code or id from an id, code or label
|
||||
*
|
||||
* @param int $id Id or code of country
|
||||
* @param int $searchkey Id or code of country to search
|
||||
* @param int $withcode '0'=Return label,
|
||||
* '1'=Return code + label,
|
||||
* '2'=Return code from id,
|
||||
@ -215,15 +215,16 @@ function societe_admin_prepare_head($object)
|
||||
* 'all'=Return array('id'=>,'code'=>,'label'=>)
|
||||
* @param DoliDB $dbtouse Database handler (using in global way may fail because of conflicts with some autoload features)
|
||||
* @param Translate $outputlangs Langs object for output translation
|
||||
* @param int $entconv 0=Return value without entities and not converted to output charset
|
||||
* @param int $entconv 0=Return value without entities and not converted to output charset, 1=Ready for html output
|
||||
* @param int $searchlabel Label of country to search (warning: searching on label is not reliable)
|
||||
* @return mixed String with country code or translated country name or Array('id','code','label')
|
||||
*/
|
||||
function getCountry($id,$withcode='',$dbtouse=0,$outputlangs='',$entconv=1)
|
||||
function getCountry($searchkey,$withcode='',$dbtouse=0,$outputlangs='',$entconv=1,$searchlabel='')
|
||||
{
|
||||
global $db,$langs;
|
||||
|
||||
// Check parameters
|
||||
if (empty($id))
|
||||
if (empty($searchkey) && empty($searchlabel))
|
||||
{
|
||||
if ($withcode === 'all') return array('id'=>'','code'=>'','label'=>'');
|
||||
else return '';
|
||||
@ -232,8 +233,9 @@ function getCountry($id,$withcode='',$dbtouse=0,$outputlangs='',$entconv=1)
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
|
||||
$sql = "SELECT rowid, code, libelle FROM ".MAIN_DB_PREFIX."c_pays";
|
||||
if (is_numeric($id)) $sql.= " WHERE rowid=".$id;
|
||||
else $sql.= " WHERE code='".$db->escape($id)."'";
|
||||
if (is_numeric($searchkey)) $sql.= " WHERE rowid=".$searchkey;
|
||||
elseif (! empty($searchkey)) $sql.= " WHERE code='".$db->escape($searchkey)."'";
|
||||
else $sql.= " WHERE libelle='".$db->escape($searchlabel)."'";
|
||||
|
||||
dol_syslog("Company.lib::getCountry sql=".$sql);
|
||||
$resql=$dbtouse->query($sql);
|
||||
@ -259,6 +261,7 @@ function getCountry($id,$withcode='',$dbtouse=0,$outputlangs='',$entconv=1)
|
||||
{
|
||||
return 'NotDefined';
|
||||
}
|
||||
$dbtouse->free($resql);
|
||||
}
|
||||
else dol_print_error($dbtouse,'');
|
||||
return 'Error';
|
||||
|
||||
@ -337,19 +337,11 @@ function dol_stringtotime($string, $gm=1)
|
||||
if ($syear >= 50 && $syear < 100) $syear+=2000;
|
||||
$string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
|
||||
}
|
||||
// Convert date with format RFC3339
|
||||
else if (preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/i',$string,$reg))
|
||||
{
|
||||
$syear = $reg[1];
|
||||
$smonth = $reg[2];
|
||||
$sday = $reg[3];
|
||||
$shour = $reg[4];
|
||||
$smin = $reg[5];
|
||||
$ssec = $reg[6];
|
||||
$string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
|
||||
}
|
||||
// Convert date with format YYYYMMDDTHHMMSSZ
|
||||
else if (preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z$/i',$string,$reg))
|
||||
else if (
|
||||
preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/i',$string,$reg) // Convert date with format RFC3339
|
||||
|| preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/i',$string,$reg) // Convert date with format YYYY-MM-DD HH:MM:SS
|
||||
|| preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z$/i',$string,$reg) // Convert date with format YYYYMMDDTHHMMSSZ
|
||||
)
|
||||
{
|
||||
$syear = $reg[1];
|
||||
$smonth = $reg[2];
|
||||
|
||||
@ -306,6 +306,11 @@ class DateLibTest extends PHPUnit_Framework_TestCase
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(7200,$result);
|
||||
|
||||
$stime='1970-01-01 02:00:00';
|
||||
$result=dol_stringtotime($stime);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(7200,$result);
|
||||
|
||||
$stime='19700101T020000Z';
|
||||
$result=dol_stringtotime($stime);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user