2
0
forked from Wavyzz/dolibarr

class conference or booth or and table actioncomm ok

This commit is contained in:
Florian HENRY
2021-03-02 22:23:54 +01:00
parent 6862c206aa
commit e5e3abd685
5 changed files with 79 additions and 290 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
*/
@@ -509,7 +524,10 @@ 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 .= "'".$this->db->idate($now)."', ";
$sql .= (strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : "null").", ";
@@ -539,14 +557,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 : "null");
$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->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 +724,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,";
@@ -717,13 +744,14 @@ class ActionComm extends CommonObject
$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 .= " num_vote, event_paid, 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 +826,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 +1112,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);
@@ -1760,6 +1801,7 @@ class ActionComm extends CommonObject
$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 .= " num_vote, event_paid, 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 +1931,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 +2124,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

@@ -132,43 +132,6 @@ class ConferenceOrBooth extends ActionComm
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
*
@@ -181,7 +144,7 @@ class ConferenceOrBooth extends ActionComm
$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;
@@ -221,111 +184,19 @@ class ConferenceOrBooth extends ActionComm
*/
public function create(User $user, $notrigger = false)
{
if (empty($this->datec)) {
$this->datec = $this->db->idate(dol_now());
}
if (! (int) $this->fk_user_author > 0) {
$this->fk_user_author = $user->id;
}
if (! (int) $this->fk_user_mod > 0) {
$this->fk_user_mod = $user->id;
}
//TODO set percent according status
$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)
{
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();
public function setPercentageFromStatus() {
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, '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, 'datec')) {
$object->date_creation = dol_now();
}
// ...
// 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, 'fk_soc') && $this->fk_soc == $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;
}
}
@@ -338,27 +209,10 @@ class ConferenceOrBooth extends ActionComm
*/
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.
*
@@ -450,11 +304,8 @@ class ConferenceOrBooth extends ActionComm
*/
public function update(User $user, $notrigger = false)
{
if (! (int) $this->fk_user_mod > 0) {
$this->fk_user_mod = $user->id;
}
return $this->updateCommon($user, $notrigger,'id');
$this->setPercentageFromStatus();
return parent::update($user, $notrigger);
}
/**
@@ -466,29 +317,10 @@ class ConferenceOrBooth extends ActionComm
*/
public function delete(User $user, $notrigger = false)
{
return $this->deleteCommon($user, $notrigger,0,'id');
//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
*
@@ -510,14 +342,6 @@ class ConferenceOrBooth extends ActionComm
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();
@@ -587,7 +411,7 @@ class ConferenceOrBooth extends ActionComm
// Set new ref and current status
if (!$error) {
$this->ref = $num;
$this->status = self::STATUS_VALIDATED;
$this->status = self::STATUS_CONFIRMED;
}
if (!$error) {
@@ -893,61 +717,6 @@ class ConferenceOrBooth extends ActionComm
}
}
/**
* 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.
*
@@ -1017,30 +786,3 @@ class ConferenceOrBooth extends ActionComm
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

@@ -49,7 +49,7 @@ insert into llx_c_actioncomm (id, code, type, libelle, module, active, position)
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);
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,8 +188,9 @@ 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 eventorg_num_vote integer;
ALTER TABLE llx_actioncomm ADD COLUMN eventorg_is_booth_paid smallint NOT NULL DEFAULT 0;
ALTER TABLE llx_actioncomm ADD COLUMN ref varchar(30);
ALTER TABLE llx_actioncomm ADD COLUMN num_vote integer;
ALTER TABLE llx_actioncomm ADD COLUMN event_paid smallint NOT NULL DEFAULT 0;
ALTER TABLE llx_actioncomm ADD COLUMN status smallint NOT NULL DEFAULT 0;
# TODO manage ref into cationcomm class
@@ -198,10 +199,10 @@ ALTER TABLE llx_actioncomm ADD COLUMN ref varchar(255);
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);
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

@@ -24,7 +24,7 @@
create table llx_actioncomm
(
id integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(255),
ref varchar(30),
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
@@ -73,9 +73,9 @@ create table llx_actioncomm
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, -- use for Event Organization module
num_vote integer , -- 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
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, ...)