FIX auto open contract if one result found

This commit is contained in:
Laurent Destailleur 2018-03-24 18:28:06 +01:00
parent 630ed04e17
commit 6ef1dbbe0f
6 changed files with 451 additions and 464 deletions

View File

@ -2500,7 +2500,6 @@ class Adherent extends CommonObject
/** /**
* Send reminders by emails before subscription end * Send reminders by emails before subscription end
* CAN BE A CRON TASK * CAN BE A CRON TASK
@ -2512,6 +2511,7 @@ class Adherent extends CommonObject
{ {
global $conf, $langs, $mysoc, $user; global $conf, $langs, $mysoc, $user;
$error = 0;
$this->output = ''; $this->output = '';
$this->error=''; $this->error='';
@ -2561,9 +2561,6 @@ class Adherent extends CommonObject
$adherent->fetch_thirdparty(); $adherent->fetch_thirdparty();
// Send reminder email // Send reminder email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail=new FormMail($db);
$outputlangs = new Translate('', $conf); $outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang); $outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang);
$outputlangs->loadLangs(array("main", "members")); $outputlangs->loadLangs(array("main", "members"));

View File

@ -1654,6 +1654,7 @@ class ActionComm extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$error = 0;
$this->output = ''; $this->output = '';
$this->error=''; $this->error='';
@ -1668,6 +1669,8 @@ class ActionComm extends CommonObject
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$this->db->begin();
// TODO Scan events of type 'email' into table llx_actioncomm_reminder with status todo, send email, then set status to done // TODO Scan events of type 'email' into table llx_actioncomm_reminder with status todo, send email, then set status to done
@ -1676,7 +1679,9 @@ class ActionComm extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'";
$this->db->query($sql); $this->db->query($sql);
return 0; $this->db->commit();
return $error;
} }
} }

View File

@ -205,8 +205,6 @@ $formother = new FormOther($db);
$socstatic = new Societe($db); $socstatic = new Societe($db);
$contracttmp = new Contrat($db); $contracttmp = new Contrat($db);
llxHeader('', $langs->trans("Contracts"));
$sql = 'SELECT'; $sql = 'SELECT';
$sql.= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; $sql.= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,";
$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
@ -309,9 +307,29 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql.= $db->plimit($limit + 1, $offset); $sql.= $db->plimit($limit + 1, $offset);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if (! $resql)
{ {
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
// Direct jump if only one record found
if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
{
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/contrat/card.php?id='.$id);
exit;
}
// Output page
// --------------------------------------------------------------------
llxHeader('', $langs->trans("Contracts"));
$i = 0; $i = 0;
$arrayofselected=is_array($toselect)?$toselect:array(); $arrayofselected=is_array($toselect)?$toselect:array();
@ -787,11 +805,6 @@ if ($resql)
$delallowed=$user->rights->contrat->lire; $delallowed=$user->rights->contrat->lire;
print $formfile->showdocuments('massfilesarea_contract','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); print $formfile->showdocuments('massfilesarea_contract','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
}
else
{
dol_print_error($db);
}
llxFooter(); llxFooter();

View File

@ -449,7 +449,6 @@ class Utils
} }
} }
return 0; return 0;
} }

View File

@ -470,14 +470,23 @@ class MyObject extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
//$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
$error = 0;
$this->output = ''; $this->output = '';
$this->error=''; $this->error='';
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$now = dol_now();
$this->db->begin();
// ... // ...
return 0; $this->db->commit();
return $error;
} }
} }

View File

@ -504,40 +504,4 @@ class SocieteAccount extends CommonObject
{ {
$this->initAsSpecimenCommon(); $this->initAsSpecimenCommon();
} }
/**
* Action executed by scheduler
* CAN BE A CRON TASK
*
* @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
*/
public function doScheduledJob()
{
global $conf, $langs;
$this->output = '';
$this->error='';
dol_syslog(__METHOD__, LOG_DEBUG);
// ...
return 0;
} }
}
/**
* Class societeAccountLine. You can also remove this and generate a CRUD class for lines objects.
*/
/*
class societeAccountLine
{
// @var int ID
public $id;
// @var mixed Sample line property 1
public $prop1;
// @var mixed Sample line property 2
public $prop2;
}
*/