Skip to content
Permalink
Browse files

Remove Dolibarr 3.3 support

  • Loading branch information
fappels committed Nov 27, 2019
1 parent b764252 commit d71a430e52aac66ec74b67297b7f5c8c0f958647
@@ -221,11 +221,8 @@ function readActionList(stdClass $params)
if (isset($params->include_total)) {
$includeTotal = $params->include_total;
}
if (ExtDirect::checkDolVersion() >= 3.4) {
$sqlFields = 'SELECT a.id, a.label, a.datep, a.datep2 as datef, a.percent as percentage, s.nom as companyname, c.lastname, c.firstname, s.rowid as company_id, c.rowid as contact_id';
} else {
$sqlFields = 'SELECT a.id, a.label, a.datep, a.datep2 as datef, a.percent as percentage, s.nom as companyname, c.name as lastname, c.firstname, s.rowid as company_id, c.rowid as contact_id';
}
$sqlFields = 'SELECT a.id, a.label, a.datep, a.datep2 as datef, a.percent as percentage, s.nom as companyname, c.lastname, c.firstname, s.rowid as company_id, c.rowid as contact_id';
$sqlFrom = ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
$sqlFrom .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON a.fk_soc = s.rowid';
$sqlFrom .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as c ON a.fk_contact = c.rowid';
@@ -246,11 +243,7 @@ function readActionList(stdClass $params)
$sqlWhere.= "(ac.type = '".$this->db->escape($filter->value)."')";
else if ($filter->property == 'content') {
$contentValue = strtolower($filter->value);
if (ExtDirect::checkDolVersion() >= 3.4) {
$sqlWhere.= " (LOWER(c.lastname) like '%".$contentValue."%' OR LOWER(c.firstname) like '%".$contentValue."%'";
} else {
$sqlWhere.= " (LOWER(c.name) like '%".$contentValue."%' OR LOWER(c.firstname) like '%".$contentValue."%'";
}
$sqlWhere.= " (LOWER(c.lastname) like '%".$contentValue."%' OR LOWER(c.firstname) like '%".$contentValue."%'";
$sqlWhere.= " OR LOWER(s.nom) like '%".$contentValue."%' OR LOWER(a.label) like '%".$contentValue."%')" ;
} else break;
if ($key < ($filterSize-1)) {
@@ -497,18 +490,10 @@ function getAllUsers()
array_push($results, $row);
$sql = "SELECT u.rowid, u.firstname,";
if (ExtDirect::checkDolVersion() >= 3.4) {
$sql.= " u.lastname";
} else {
$sql.= " u.name as lastname";
}
$sql.= " u.lastname";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
if (ExtDirect::checkDolVersion() >= 3.4) {
$sql .= " ORDER BY u.lastname ASC ";
} else {
$sql .= " ORDER BY u.name ASC ";
}
$sql .= " ORDER BY u.lastname ASC ";
$resql=$this->db->query($sql);
if ($resql) {
@@ -155,16 +155,14 @@ public function readAuthentication(stdClass $param)
$result->connector_description = $moduleInfo->description;
$result->connector_version = $moduleInfo->version;
$result->dolibarr_version = ExtDirect::checkDolVersion();
if (ExtDirect::checkDolVersion() >= 3.4) {
$mysoc = new Societe($this->db);
$conf->setValues($this->db);//update $conf globals
$mysoc->setMysoc($conf);
$result->home_country_id = $mysoc->country_id;
$result->home_state_id = $mysoc->state_id;
$result->home_name = $mysoc->name;
$result->home_localtax1_assuj = $mysoc->localtax1_assuj;
$result->home_localtax2_assuj = $mysoc->localtax2_assuj;
}
$mysoc = new Societe($this->db);
$conf->setValues($this->db);//update $conf globals
$mysoc->setMysoc($conf);
$result->home_country_id = $mysoc->country_id;
$result->home_state_id = $mysoc->state_id;
$result->home_name = $mysoc->name;
$result->home_localtax1_assuj = $mysoc->localtax1_assuj;
$result->home_localtax2_assuj = $mysoc->localtax2_assuj;
$result->timezone_offset = getServerTimeZoneInt('now');
$result->timezone = getServerTimeZoneString();
return $result;
@@ -90,42 +90,24 @@ public function readCategorie(stdClass $param)
else if ($filter->property == 'label') $label=$filter->value;
}
}
if (($id > 0) || ($label != '')) {
if (ExtDirect::checkDolVersion() >= 3.4) {
if (($result = $this->fetch($id, $label)) < 0) return $result;
if (!$this->error) {
$row->id = $this->id ;
$row->fk_parent = $this->fk_parent;
$row->label = $this->label;
$row->description = $this->description?$this->description:'';
$row->company_id = $this->socid;
// 0=Product, 1=Supplier, 2=Customer/Prospect, 3=Member
$row->type= $this->type;
$row->entity= $this->entity;
array_push($results, $row);
} else {
return 0;
}
if (($result = $this->fetch($id, $label)) < 0) return $result;
if (!$this->error) {
$row->id = $this->id ;
$row->fk_parent = $this->fk_parent;
$row->label = $this->label;
$row->description = $this->description?$this->description:'';
$row->company_id = $this->socid;
// 0=Product, 1=Supplier, 2=Customer/Prospect, 3=Member
$row->type= $this->type;
$row->entity= $this->entity;
array_push($results, $row);
} else {
for ($type = 0; $type < 4; $type++) {
if (($result = $this->rechercher($id, $label, $type)) < 0) return $result;
if (! empty($result)) {
$cat = $result[0];
$row->id = $cat->id ;
$row->fk_parent = $cat->fk_parent;
$row->label = $cat->label;
$row->description = $cat->description?$cat->description:'';
$row->company_id = $cat->socid;
// 0=Product, 1=Supplier, 2=Customer/Prospect, 3=Member
$row->type= $cat->type;
$row->entity= $cat->entity;
array_push($results, $row);
}
}
}
return 0;
}
}
return $results;
}
@@ -223,14 +223,10 @@ function readContactList(stdClass $params)
if (isset($params->include_total)) {
$includeTotal = $params->include_total;
}
if (ExtDirect::checkDolVersion() >= 3.4) {
if (ExtDirect::checkDolVersion() >= 3.5) {
$sqlFields = 'SELECT c.rowid as id, s.rowid as company_id, s.nom as companyname, c.lastname, c.firstname,c.zip as zip, c.town as town, c.statut';
} else {
$sqlFields = 'SELECT c.rowid as id, s.rowid as company_id, s.nom as companyname, c.lastname, c.firstname,c.zip as zip, c.town as town';
}
if (ExtDirect::checkDolVersion() >= 3.5) {
$sqlFields = 'SELECT c.rowid as id, s.rowid as company_id, s.nom as companyname, c.lastname, c.firstname,c.zip as zip, c.town as town, c.statut';
} else {
$sqlFields = 'SELECT c.rowid as id, s.rowid as company_id, s.nom as companyname, c.name as lastname, c.firstname,c.cp as zip, c.ville as town';
$sqlFields = 'SELECT c.rowid as id, s.rowid as company_id, s.nom as companyname, c.lastname, c.firstname,c.zip as zip, c.town as town';
}
$sqlFrom = ' FROM '.MAIN_DB_PREFIX.'socpeople as c';
$sqlFrom .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid';
@@ -243,22 +239,12 @@ function readContactList(stdClass $params)
else if ($filter->property == 'company_id')
$sqlWhere .= '(s.rowid = '.$filter->value.' AND s.entity IN ('.getEntity('societe', 1).'))';
else if ($filter->property == 'town') {
if (ExtDirect::checkDolVersion() >= 3.4) {
$sqlWhere .= "c.town = '".$this->db->escape($filter->value)."'";
} else {
$sqlWhere .= "c.ville = '".$this->db->escape($filter->value)."'";
}
}
$sqlWhere .= "c.town = '".$this->db->escape($filter->value)."'";
}
else if ($filter->property == 'content') {
$contentValue = $this->db->escape(strtolower($filter->value));
if (ExtDirect::checkDolVersion() >= 3.4) {
$sqlWhere.= " (LOWER(c.lastname) like '%".$contentValue."%' OR LOWER(c.firstname) like '%".$contentValue."%'";
$sqlWhere.= " OR LOWER(c.town) like '%".$contentValue."%' OR LOWER(c.zip) like '%".$contentValue."%')" ;
} else {
$sqlWhere.= " (LOWER(c.name) like '%".$contentValue."%' OR LOWER(c.firstname) like '%".$contentValue."%'";
$sqlWhere.= " OR LOWER(c.ville) like '%".$contentValue."%' OR LOWER(c.cp) like '%".$contentValue."%')" ;
}
$sqlWhere.= " (LOWER(c.lastname) like '%".$contentValue."%' OR LOWER(c.firstname) like '%".$contentValue."%'";
$sqlWhere.= " OR LOWER(c.town) like '%".$contentValue."%' OR LOWER(c.zip) like '%".$contentValue."%')" ;
} else break;
if ($key < ($filterSize-1)) {
if($filter->property == $params->filter[$key+1]->property) $sqlWhere .= ' OR ';
@@ -480,23 +466,11 @@ public function fileUpload($params)
private function prepareFields($params)
{
($params->civility_id) ? ($this->civilite_id = $params->civility_id) : null;
if (ExtDirect::checkDolVersion() >= 3.4) {
($params->lastname) ? ($this->lastname = $params->lastname) : null;
} else {
($params->lastname) ? ($this->name = $params->lastname) : null;
}
($params->lastname) ? ($this->lastname = $params->lastname) : null;
($params->firstname) ? ($this->firstname = $params->firstname) : null;
($params->address) ? ($this->address = $params->address) : null;
if (ExtDirect::checkDolVersion() >= 3.4) {
($params->zip) ? ($this->zip = $params->zip) : null;
} else {
($params->zip) ? ($this->cp = $params->zip) : null;
}
if (ExtDirect::checkDolVersion() >= 3.4) {
($params->town) ? ($this->town = $params->town) : null;
} else {
($params->town) ? ($this->ville = $params->town) : null;
}
($params->zip) ? ($this->zip = $params->zip) : null;
($params->town) ? ($this->town = $params->town) : null;
($params->fax) ? ($this->fax = $params->fax) : null;
($params->phone_perso) ? ($this->phone_perso = $params->phone_perso) : null;
($params->skype) ? ($this->skype = $params->skype) : null;

0 comments on commit d71a430

Please sign in to comment.
You can’t perform that action at this time.