2
0
forked from Wavyzz/dolibarr

Merge pull request #16520 from FHenry/dev_EventOrganisation

new: working on conference or booth object and event type #FoundationFunding
This commit is contained in:
Laurent Destailleur
2021-03-04 17:06:57 +01:00
committed by GitHub
11 changed files with 182 additions and 394 deletions

View File

@@ -349,6 +349,21 @@ class ActionComm extends CommonObject
*/
public $errors_to;
/**
* @var int number of vote for an event
*/
public $num_vote;
/**
* @var int if event is paid
*/
public $event_paid;
/**
* @var int status use but Event organisation module
*/
public $status;
/**
* Typical value for a event that is in a todo state
*/
@@ -481,7 +496,8 @@ class ActionComm extends CommonObject
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm";
$sql .= "(datec,";
$sql .= "(ref,";
$sql .= "datec,";
$sql .= "datep,";
$sql .= "datep2,";
$sql .= "durationp,"; // deprecated
@@ -509,8 +525,12 @@ class ActionComm extends CommonObject
$sql .= "email_tocc,";
$sql .= "email_tobcc,";
$sql .= "email_subject,";
$sql .= "errors_to";
$sql .= "errors_to,";
$sql .= "num_vote,";
$sql .= "event_paid,";
$sql .= "status";
$sql .= ") VALUES (";
$sql .= "'(PROV)', ";
$sql .= "'".$this->db->idate($now)."', ";
$sql .= (strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : "null").", ";
$sql .= (strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : "null").", ";
@@ -539,14 +559,23 @@ class ActionComm extends CommonObject
$sql .= (!empty($this->email_tocc) ? "'".$this->db->escape($this->email_tocc)."'" : "null").", ";
$sql .= (!empty($this->email_tobcc) ? "'".$this->db->escape($this->email_tobcc)."'" : "null").", ";
$sql .= (!empty($this->email_subject) ? "'".$this->db->escape($this->email_subject)."'" : "null").", ";
$sql .= (!empty($this->errors_to) ? "'".$this->db->escape($this->errors_to)."'" : "null");
$sql .= (!empty($this->errors_to) ? "'".$this->db->escape($this->errors_to)."'" : "null").", ";
$sql .= (!empty($this->num_vote) ? (int) $this->num_vote : "null").", ";
$sql .= (!empty($this->event_paid) ? (int) $this->event_paid : 0).", ";
$sql .= (!empty($this->status) ? (int) $this->status : "0");
$sql .= ")";
dol_syslog(get_class($this)."::add", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$this->ref = $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id");
$sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm SET ref='".$this->db->escape($this->ref)."' WHERE id=".$this->id;
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
dol_syslog('Error to process ref: '.$this->db->lasterror(), LOG_ERR);
$this->errors[] = $this->db->lasterror();
}
// Now insert assigned users
if (!$error) {
//dol_syslog(var_export($this->userassigned, true));
@@ -697,7 +726,7 @@ class ActionComm extends CommonObject
global $langs;
$sql = "SELECT a.id,";
$sql .= " a.id as ref,";
$sql .= " a.ref as ref,";
$sql .= " a.entity,";
$sql .= " a.ref_ext,";
$sql .= " a.datep,";
@@ -716,14 +745,15 @@ class ActionComm extends CommonObject
$sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,";
$sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,";
$sql .= " s.nom as socname,";
$sql .= " u.firstname, u.lastname as lastname";
$sql .= " u.firstname, u.lastname as lastname,";
$sql .= " num_vote, event_paid, a.status";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a ";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id ";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc";
$sql .= " WHERE ";
if ($ref) {
$sql .= " a.id = ".((int) $ref); // No field ref, we use id
$sql .= " a.ref = '".$this->db->escape($ref)."'";
} elseif ($ref_ext) {
$sql .= " a.ref_ext = '".$this->db->escape($ref_ext)."'";
} elseif ($email_msgid) {
@@ -798,6 +828,10 @@ class ActionComm extends CommonObject
$this->elementid = $obj->elementid;
$this->elementtype = $obj->elementtype;
$this->num_vote = $obj->num_vote;
$this->event_paid = $obj->event_paid;
$this->status = $obj->status;
$this->fetchResources();
}
$this->db->free($resql);
@@ -1080,6 +1114,15 @@ class ActionComm extends CommonObject
if (!empty($this->elementtype)) {
$sql .= ", elementtype=".($this->elementtype ? "'".$this->db->escape($this->elementtype)."'" : "null");
}
if (!empty($this->num_vote)) {
$sql .= ", num_vote=".($this->num_vote ? (int) $this->num_vote : null);
}
if (!empty($this->event_paid)) {
$sql .= ", event_paid=".($this->event_paid ? (int) $this->event_paid : 0);
}
if (!empty($this->status)) {
$sql .= ", status=".($this->status ? (int) $this->status : 0);
}
$sql .= " WHERE id=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@@ -1759,7 +1802,8 @@ class ActionComm extends CommonObject
$sql .= " a.priority, a.fulldayevent, a.location, a.transparency,";
$sql .= " u.firstname, u.lastname, u.email,";
$sql .= " s.nom as socname,";
$sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label";
$sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label,";
$sql .= " num_vote, event_paid, a.status";
$sql .= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc";
@@ -1889,6 +1933,9 @@ class ActionComm extends CommonObject
$event['url'] = $url;
$event['created'] = $this->db->jdate($obj->datec) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
$event['modified'] = $this->db->jdate($obj->datem) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
$event['num_vote'] = $this->num_vote;
$event['event_paid'] = $this->event_paid;
$event['status'] = $this->status;
// TODO: find a way to call "$this->fetch_userassigned();" without override "$this" properties
$this->id = $obj->id;
@@ -2079,6 +2126,7 @@ class ActionComm extends CommonObject
$this->datef = $now;
$this->fulldayevent = 0;
$this->percentage = 0;
$this->status = 0;
$this->location = 'Location';
$this->transparency = 1; // 1 means opaque
$this->priority = 1;

View File

@@ -153,7 +153,7 @@ class CActionComm
public function liste_array($active = '', $idorcode = 'id', $excludetype = '', $onlyautoornot = 0, $morefilter = '', $shortlabel = 0)
{
// phpcs:enable
global $langs, $conf;
global $langs, $conf, $user;
$langs->load("commercial");
$repid = array();
@@ -191,23 +191,29 @@ class CActionComm
$qualified = 0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO)
}
if ($qualified && $obj->module) {
if ($obj->module == 'invoice' && !$conf->facture->enabled) {
if ($qualified && !empty($obj->module)) {
if ($obj->module == 'invoice' && empty($conf->facture->enabled) && empty($user->facture->lire)) {
$qualified = 0;
}
if ($obj->module == 'order' && !$conf->commande->enabled) {
if ($obj->module == 'order' && empty($conf->commande->enabled) && empty($user->commande->lire)) {
$qualified = 0;
}
if ($obj->module == 'propal' && !$conf->propal->enabled) {
if ($obj->module == 'propal' && empty($conf->propal->enabled) && empty($user->propale->lire)) {
$qualified = 0;
}
if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_invoice->enabled)) {
if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || empty($conf->supplier_invoice->enabled)) && empty($user->fournisseur->facture->lire)) {
$qualified = 0;
}
if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_order->enabled)) {
if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || empty($conf->supplier_order->enabled)) && empty($user->fournisseur->commande->lire)) {
$qualified = 0;
}
if ($obj->module == 'shipping' && !$conf->expedition->enabled) {
if ($obj->module == 'shipping' && empty($conf->expedition->enabled) && empty($user->expedition->lire)) {
$qualified = 0;
}
if (preg_match('/@eventorganization/', $obj->module) && empty($conf->eventorganization->enabled) && empty($user->eventorganization->read)) {
$qualified = 0;
}
if (!preg_match('/^system/', $obj->type) && isset($conf->{$obj->module}) && empty($conf->{$obj->module}->enabled)) {
$qualified = 0;
}
}
@@ -247,12 +253,18 @@ class CActionComm
$repcode['AC_ALL_AUTO'] = '-- '.$langs->trans("ActionAC_AUTO");
}
if ($typecalendar == 'module') {
//TODO check if possible to push it between system and systemauto
if (preg_match('/@/', $obj->module)) {
$module = explode('@', $obj->module)[1];
} else {
$module = $obj->module;
}
$label = '   '.$label;
if (!isset($repcode['AC_ALL_'.strtoupper($obj->module)])) { // If first time for this module
if (!isset($repcode['AC_ALL_'.strtoupper($module)])) { // If first time for this module
$idforallfornewmodule--;
}
$repid[$idforallfornewmodule] = $langs->trans("ActionAC_ALL_".strtoupper($obj->module));
$repcode['AC_ALL_'.strtoupper($obj->module)] = '-- '.$langs->trans("Module").' '.ucfirst($obj->module);
$repid[$idforallfornewmodule] = $langs->trans("ActionAC_ALL_".strtoupper($module));
$repcode['AC_ALL_'.strtoupper($module)] = '-- '.$langs->trans("Module").' '.ucfirst($module);
}
}
$repid[$obj->id] = $label;

View File

@@ -24,13 +24,13 @@
// Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
/**
* Class for ConferenceOrBooth
*/
class ConferenceOrBooth extends CommonObject
class ConferenceOrBooth extends ActionComm
{
/**
* @var string ID of module.
@@ -65,8 +65,11 @@ class ConferenceOrBooth extends CommonObject
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1;
const STATUS_CANCELED = 9;
const STATUS_SUGGESTED = 1;
const STATUS_CONFIRMED = 2;
const STATUS_NOT_QUALIFIED = 3;
const STATUS_DONE = 4;
const STATUS_CANCELED = -1;
/**
@@ -100,82 +103,35 @@ class ConferenceOrBooth extends CommonObject
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
public $fields=array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"),
'id' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'ref' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'help'=>"Help text", 'showoncombobox'=>'1',),
//'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"Help text for amount",),
//'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'css'=>'maxwidth75imp', 'help'=>"Help text for quantity",),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3,),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,),
'fk_action' => array('type'=>'sellist:c_actioncomm:label:rowid::module LIKE (\'conference\',\'booth\'))', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1,),
'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
'fk_user_author' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
'fk_user_mod' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validé', '9'=>'Annulé'),),
);
public $rowid;
public $ref;
public $id;
public $label;
public $amount;
public $qty;
public $fk_soc;
public $fk_project;
public $description;
public $note_public;
public $note_private;
public $date_creation;
public $note;
public $fk_action;
public $datec;
public $tms;
public $fk_user_creat;
public $fk_user_modif;
public $last_main_doc;
public $fk_user_author;
public $fk_user_mod;
public $import_key;
public $model_pdf;
public $status;
// END MODULEBUILDER PROPERTIES
// If this object has a subtable with lines
// /**
// * @var string Name of subtable line
// */
// public $table_element_line = 'eventorganization_conferenceorboothline';
// /**
// * @var string Field with ID of parent key if this object has a parent
// */
// public $fk_element = 'fk_conferenceorbooth';
// /**
// * @var string Name of subtable class that manage subtable lines
// */
// public $class_element_line = 'ConferenceOrBoothline';
// /**
// * @var array List of child tables. To test if we can delete object.
// */
// protected $childtables = array();
// /**
// * @var array List of child tables. To know object to delete on cascade.
// * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
// * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
// */
// protected $childtablesoncascade = array('eventorganization_conferenceorboothdet');
// /**
// * @var ConferenceOrBoothLine[] Array of subtable lines
// */
// public $lines = array();
/**
* Constructor
*
@@ -188,7 +144,7 @@ class ConferenceOrBooth extends CommonObject
$this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['rowid']['visible'] = 0;
$this->fields['id']['visible'] = 0;
}
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
@@ -228,105 +184,20 @@ class ConferenceOrBooth extends CommonObject
*/
public function create(User $user, $notrigger = false)
{
return $this->createCommon($user, $notrigger);
$this->setPercentageFromStatus();
return parent::create($user, $notrigger);
}
/**
* Clone an object into another one
*
* @param User $user User that creates
* @param int $fromid Id of object to clone
* @return mixed New object created, <0 if KO
* Set Percentage from status
*/
public function createFromClone(User $user, $fromid)
public function setPercentageFromStatus()
{
global $langs, $extrafields;
$error = 0;
dol_syslog(__METHOD__, LOG_DEBUG);
$object = new self($this->db);
$this->db->begin();
// Load source object
$result = $object->fetchCommon($fromid);
if ($result > 0 && !empty($object->table_element_line)) {
$object->fetchLines();
if ($this->status==self::STATUS_DONE) {
$this->percentage=100;
}
// get lines so they will be clone
//foreach($this->lines as $line)
// $line->fetch_optionals();
// Reset some properties
unset($object->id);
unset($object->fk_user_creat);
unset($object->import_key);
// Clear fields
if (property_exists($object, 'ref')) {
$object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
}
if (property_exists($object, 'label')) {
$object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
}
if (property_exists($object, 'status')) {
$object->status = self::STATUS_DRAFT;
}
if (property_exists($object, 'date_creation')) {
$object->date_creation = dol_now();
}
if (property_exists($object, 'date_modification')) {
$object->date_modification = null;
}
// ...
// Clear extrafields that are unique
if (is_array($object->array_options) && count($object->array_options) > 0) {
$extrafields->fetch_name_optionals_label($this->table_element);
foreach ($object->array_options as $key => $option) {
$shortkey = preg_replace('/options_/', '', $key);
if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
//var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
unset($object->array_options[$key]);
}
}
}
// Create clone
$object->context['createfromclone'] = 'createfromclone';
$result = $object->createCommon($user);
if ($result < 0) {
$error++;
$this->error = $object->error;
$this->errors = $object->errors;
}
if (!$error) {
// copy internal contacts
if ($this->copy_linked_contact($object, 'internal') < 0) {
$error++;
}
}
if (!$error) {
// copy external contacts if same company
if (property_exists($this, 'socid') && $this->socid == $object->socid) {
if ($this->copy_linked_contact($object, 'external') < 0) {
$error++;
}
}
}
unset($object->context['createfromclone']);
// End
if (!$error) {
$this->db->commit();
return $object;
} else {
$this->db->rollback();
return -1;
if ($this->status==self::STATUS_DRAFT) {
$this->percentage=0;
}
}
@@ -339,27 +210,10 @@ class ConferenceOrBooth extends CommonObject
*/
public function fetch($id, $ref = null)
{
$result = $this->fetchCommon($id, $ref);
if ($result > 0 && !empty($this->table_element_line)) {
$this->fetchLines();
}
$result = parent::fetch($id, $ref);
return $result;
}
/**
* Load object lines in memory from the database
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
public function fetchLines()
{
$this->lines = array();
$result = $this->fetchLinesCommon();
return $result;
}
/**
* Load list of objects in memory from the database.
*
@@ -373,6 +227,8 @@ class ConferenceOrBooth extends CommonObject
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
//TODO set percent according status
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -391,7 +247,7 @@ class ConferenceOrBooth extends CommonObject
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
if ($key == 't.rowid') {
if ($key == 't.id') {
$sqlwhere[] = $key.'='.$value;
} elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
$sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
@@ -449,7 +305,8 @@ class ConferenceOrBooth extends CommonObject
*/
public function update(User $user, $notrigger = false)
{
return $this->updateCommon($user, $notrigger);
$this->setPercentageFromStatus();
return parent::update($user, $notrigger);
}
/**
@@ -461,29 +318,10 @@ class ConferenceOrBooth extends CommonObject
*/
public function delete(User $user, $notrigger = false)
{
return $this->deleteCommon($user, $notrigger);
//return $this->deleteCommon($user, $notrigger, 1);
//TODO delete attendees and subscription
return parent::delete($notrigger);
}
/**
* Delete a line of object in database
*
* @param User $user User that delete
* @param int $idline Id of line to delete
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int >0 if OK, <0 if KO
*/
public function deleteLine(User $user, $idline, $notrigger = false)
{
if ($this->status < 0) {
$this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
return -2;
}
return $this->deleteLineCommon($user, $idline, $notrigger);
}
/**
* Validate object
*
@@ -505,55 +343,28 @@ class ConferenceOrBooth extends CommonObject
return 0;
}
/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->conferenceorbooth->write))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->conferenceorbooth->conferenceorbooth_advance->validate))))
{
$this->error='NotEnoughPermissions';
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
return -1;
}*/
$now = dol_now();
$this->db->begin();
// Define new ref
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
$num = $this->getNextNumRef();
} else {
$num = $this->ref;
// Validate
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " status = ".self::STATUS_CONFIRMED;
$sql .= " WHERE id = ".$this->id;
dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
dol_print_error($this->db);
$this->error = $this->db->lasterror();
$error++;
}
$this->newref = $num;
if (!empty($num)) {
// Validate
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET ref = '".$this->db->escape($num)."',";
$sql .= " status = ".self::STATUS_VALIDATED;
if (!empty($this->fields['date_validation'])) {
$sql .= ", date_validation = '".$this->db->idate($now)."'";
}
if (!empty($this->fields['fk_user_valid'])) {
$sql .= ", fk_user_valid = ".$user->id;
}
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
dol_print_error($this->db);
$this->error = $this->db->lasterror();
$error++;
}
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('CONFERENCEORBOOTH_VALIDATE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('CONFERENCEORBOOTH_VALIDATE', $user);
if ($result < 0) $error++;
// End call triggers
}
if (!$error) {
@@ -565,9 +376,7 @@ class ConferenceOrBooth extends CommonObject
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'conferenceorbooth/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'conferenceorbooth/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) {
$error++; $this->error = $this->db->lasterror();
}
if (!$resql) { $error++; $this->error = $this->db->lasterror(); }
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
@@ -596,7 +405,7 @@ class ConferenceOrBooth extends CommonObject
// Set new ref and current status
if (!$error) {
$this->ref = $num;
$this->status = self::STATUS_VALIDATED;
$this->status = self::STATUS_CONFIRMED;
}
if (!$error) {
@@ -643,7 +452,7 @@ class ConferenceOrBooth extends CommonObject
public function cancel($user, $notrigger = 0)
{
// Protection
if ($this->status != self::STATUS_VALIDATED) {
if ($this->status != self::STATUS_CONFIRMED) {
return 0;
}
@@ -678,7 +487,7 @@ class ConferenceOrBooth extends CommonObject
return -1;
}*/
return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'CONFERENCEORBOOTH_REOPEN');
return $this->setStatusCommon($user, self::STATUS_CONFIRMED, $notrigger, 'CONFERENCEORBOOTH_REOPEN');
}
/**
@@ -706,7 +515,7 @@ class ConferenceOrBooth extends CommonObject
$label .= ' '.$this->getLibStatut(5);
}
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->id;
$url = dol_buildpath('/eventorganization/conferenceorbooth_card.php', 1).'?id='.$this->id;
@@ -814,11 +623,17 @@ class ConferenceOrBooth extends CommonObject
global $langs;
//$langs->load("eventorganization@eventorganization");
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
$this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
$this->labelStatus[self::STATUS_SUGGESTED] = $langs->trans('Suggested');
$this->labelStatus[self::STATUS_CONFIRMED] = $langs->trans('Confirmed');
$this->labelStatus[self::STATUS_NOTSELECTED] = $langs->trans('NotSelected');
$this->labelStatus[self::STATUS_DONE] = $langs->trans('Done');
$this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Canceled');
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft');
$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled');
$this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled');
$this->labelStatusShort[self::STATUS_SUGGESTED] = $langs->trans('Suggested');
$this->labelStatusShort[self::STATUS_CONFIRMED] = $langs->trans('Confirmed');
$this->labelStatusShort[self::STATUS_NOTSELECTED] = $langs->trans('NotSelected');
$this->labelStatusShort[self::STATUS_DONE] = $langs->trans('Done');
$this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Canceled');
}
$statusType = 'status'.$status;
@@ -838,10 +653,10 @@ class ConferenceOrBooth extends CommonObject
*/
public function info($id)
{
$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
$sql .= ' fk_user_creat, fk_user_modif';
$sql = 'SELECT rowid, datec as datec, tms as datem,';
$sql .= ' fk_user_author, fk_user_mod';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id;
$sql .= ' WHERE t.id = '.$id;
$result = $this->db->query($sql);
if ($result) {
if ($this->db->num_rows($result)) {
@@ -853,21 +668,8 @@ class ConferenceOrBooth extends CommonObject
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid) {
$vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
if ($obj->fk_user_cloture) {
$cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;
}
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->datem);
$this->date_validation = $this->db->jdate($obj->datev);
}
$this->db->free($result);
@@ -909,61 +711,6 @@ class ConferenceOrBooth extends CommonObject
}
}
/**
* Returns the reference to the following non used object depending on the active numbering module.
*
* @return string Object free reference
*/
public function getNextNumRef()
{
global $langs, $conf;
$langs->load("eventorganization@eventorganization");
if (empty($conf->global->EVENTORGANIZATION_CONFERENCEORBOOTH_ADDON)) {
$conf->global->EVENTORGANIZATION_CONFERENCEORBOOTH_ADDON = 'mod_conferenceorbooth_standard';
}
if (!empty($conf->global->EVENTORGANIZATION_CONFERENCEORBOOTH_ADDON)) {
$mybool = false;
$file = $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTH_ADDON.".php";
$classname = $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTH_ADDON;
// Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/eventorganization/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
}
if ($mybool === false) {
dol_print_error('', "Failed to include file ".$file);
return '';
}
if (class_exists($classname)) {
$obj = new $classname();
$numref = $obj->getNextValue($this);
if ($numref != '' && $numref != '-1') {
return $numref;
} else {
$this->error = $obj->error;
//dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
return "";
}
} else {
print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
return "";
}
} else {
print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
return "";
}
}
/**
* Create a document onto disk according to template module.
*
@@ -1033,30 +780,3 @@ class ConferenceOrBooth extends CommonObject
return $error;
}
}
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
/**
* Class ConferenceOrBoothLine. You can also remove this and generate a CRUD class for lines objects.
*/
class ConferenceOrBoothLine extends CommonObjectLine
{
// To complete with content of an object ConferenceOrBoothLine
// We should have a field rowid, fk_conferenceorbooth and position
/**
* @var int Does object support extrafields ? 0=No, 1=Yes
*/
public $isextrafieldmanaged = 0;
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
public function __construct(DoliDB $db)
{
$this->db = $db;
}
}

View File

@@ -41,23 +41,6 @@ function conferenceorboothPrepareHead($object)
$head[$h][2] = 'card';
$h++;
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
$nbNote = 0;
if (!empty($object->note_private)) {
$nbNote++;
}
if (!empty($object->note_public)) {
$nbNote++;
}
$head[$h][0] = dol_buildpath('/eventorganization/conferenceorbooth_note.php', 1).'?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) {
$head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
}
$head[$h][2] = 'note';
$h++;
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->eventorganization->dir_output."/conferenceorbooth/".dol_sanitizeFileName($object->ref);

View File

@@ -48,3 +48,8 @@ insert into llx_c_actioncomm (id, code, type, libelle, module, active, position)
-- Code used from 3.3+ when type of event is not used
insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 40,'AC_OTH_AUTO','systemauto','Other (automatically inserted events)',NULL, 1, 20);
insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 50,'AC_OTH','system','Other (manually inserted events)',NULL, 1, 5);
INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 60,'AC_EO_ONLINECONF','module','Online/Virtual conference','conference@eventorganization', 1, 60);
INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 61,'AC_EO_INDOORCONF','module','Indoor conference','conference@eventorganization', 1, 61);
INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 62,'AC_EO_ONLINEBOOTH','module','Online/Virtual booth','booth@eventorganization', 1, 62);
INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 63,'AC_EO_INDOORBOOTH','module','Indoor booth','booth@eventorganization', 1, 63);

View File

@@ -188,7 +188,21 @@ ALTER TABLE llx_projet ADD COLUMN accept_booth_suggestions integer DEFAULT 0;
ALTER TABLE llx_projet ADD COLUMN price_registration double(24,8);
ALTER TABLE llx_projet ADD COLUMN price_booth double(24,8);
ALTER TABLE llx_actioncomm ADD COLUMN num_vote integer DEFAULT NULL AFTER reply_to;
ALTER TABLE llx_actioncomm ADD COLUMN event_paid smallint NOT NULL DEFAULT 0 AFTER num_vote;
ALTER TABLE llx_actioncomm ADD COLUMN status smallint NOT NULL DEFAULT 0 AFTER event_paid;
ALTER TABLE llx_actioncomm ADD COLUMN ref varchar(30) AFTER id;
UPDATE llx_actioncomm SET ref = id WHERE ref = '' OR ref IS NULL;
ALTER TABLE llx_actioncomm MODIFY COLUMN ref varchar(30) NOT NULL;
ALTER TABLE llx_actioncomm ADD UNIQUE INDEX uk_actioncomm_ref (ref, entity);
ALTER TABLE llx_c_actioncomm MODIFY code varchar(50) NOT NULL;
ALTER TABLE llx_c_actioncomm MODIFY module varchar(50) DEFAULT NULL;
INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 60,'AC_EO_ONLINECONF','module','Online/Virtual conference','conference@eventorganization', 1, 60);
INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 61,'AC_EO_INDOORCONF','module','Indoor conference','conference@eventorganization', 1, 61);
INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 62,'AC_EO_ONLINEBOOTH','module','Online/Virtual booth','booth@eventorganization', 1, 62);
INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 63,'AC_EO_INDOORBOOTH','module','Indoor booth','booth@eventorganization', 1, 63);
-- Code enhanced - Standardize field name
ALTER TABLE llx_commande CHANGE COLUMN tva total_tva double(24,8) default 0;
ALTER TABLE llx_supplier_proposal CHANGE COLUMN tva total_tva double(24,8) default 0;

View File

@@ -17,7 +17,6 @@
--
-- ===========================================================================
ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_fk_soc (fk_soc);
ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_fk_contact (fk_contact);
ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_code (code);
@@ -27,5 +26,6 @@ ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_fk_project (fk_project);
ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_datep (datep);
ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_datep2 (datep2);
ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_recurid (recurid);
ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_ref_ext (ref_ext);
ALTER TABLE llx_actioncomm ADD UNIQUE INDEX uk_actioncomm_ref (ref, entity);

View File

@@ -24,6 +24,7 @@
create table llx_actioncomm
(
id integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(30) NOT NULL,
ref_ext varchar(255), -- reference into an external system (not used by dolibarr). Example: An id coming from google calendar has length between 5 and 1024 chars. An event id must follow rule: chars used in base32hex encoding (i.e. lowercase letters a-v and digits 0-9, see section 3.1.2 in RFC2938)
entity integer DEFAULT 1 NOT NULL, -- multi company id
datep datetime, -- date start
@@ -31,7 +32,7 @@ create table llx_actioncomm
fk_action integer, -- type of action (optional link with id in llx_c_actioncomm or null)
code varchar(50) NULL, -- code of action for automatic action ('AC_OTH_AUTO' for automatic actions, 'AC_EMAILIN_AUTO' for email input, 'AC_xxx' for manual action...)
datec datetime, -- date creation
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- last modification date
fk_user_author integer, -- user id of user that has created record
@@ -71,7 +72,11 @@ create table llx_actioncomm
recurid varchar(128), -- used to store event id to link each other all the repeating event record. It can be the 'iCalUID' as in RFC5545 (an id similar for all the same serie)
recurrule varchar(128), -- contains string with ical format recurring rule like 'FREQ=MONTHLY;INTERVAL=2;BYMONTHDAY=19' or 'FREQ=WEEKLY;BYDAY=MO'
recurdateend datetime, -- no more recurring event after this date
num_vote integer DEFAULT NULL, -- use for Event Organization module
event_paid smallint NOT NULL DEFAULT 0, -- use for Event Organization module
status smallint NOT NULL DEFAULT 0, -- use for Event Organization module for now, but could be use after for event global status
fk_element integer DEFAULT NULL, -- For link to an element (proposal, invoice, order, ...)
elementtype varchar(255) DEFAULT NULL, -- For link to an element (proposal, invoice, order, ...)

View File

@@ -21,10 +21,10 @@
create table llx_c_actioncomm
(
id integer PRIMARY KEY,
code varchar(12) NOT NULL,
code varchar(50) NOT NULL,
type varchar(50) DEFAULT 'system' NOT NULL,
libelle varchar(48) NOT NULL,
module varchar(16) DEFAULT NULL,
module varchar(50) DEFAULT NULL,
active tinyint DEFAULT 1 NOT NULL,
todo tinyint, -- deprecated
color varchar(9),

View File

@@ -68,6 +68,7 @@ ActionAC_OTH_AUTO=Other auto
ActionAC_MANUAL=Manually inserted events
ActionAC_AUTO=Automatically inserted events
ActionAC_OTH_AUTOShort=Other
ActionAC_EVENTORGANIZATION=Event organization events
Stats=Sales statistics
StatusProsp=Prospect status
DraftPropals=Draft commercial proposals

View File

@@ -356,7 +356,7 @@ class MyObject extends CommonObject
if (!$error) {
// copy external contacts if same company
if (property_exists($this, 'socid') && $this->socid == $object->socid) {
if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
if ($this->copy_linked_contact($object, 'external') < 0) {
$error++;
}