almost done

This commit is contained in:
Florian HENRY 2021-03-24 21:21:53 +01:00
parent 373a52063d
commit e898fbb834
9 changed files with 104 additions and 1114 deletions

View File

@ -78,7 +78,7 @@ foreach ($object->fields as $key => $val) {
}
$value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
} elseif ($val['type'] == 'price') {
$value = price2num(GETPOST($key));
$value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key);
} else {
$value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key;
}

View File

@ -101,10 +101,10 @@ class ConferenceOrBoothAttendee extends CommonObject
*/
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'=>0, 'index'=>1, 'comment'=>"Reference of object"),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>2, 'index'=>1, 'comment'=>"Reference of object"),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', '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'=>4, 'index'=>1,),
'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>4, 'index'=>1,),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>0, 'index'=>1,),
'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>0, 'index'=>1,),
'email' => array('type'=>'mail', 'label'=>'Email', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>1, 'index'=>1,),
'date_subscription' => array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',),
'amount' => array('type'=>'price', 'label'=>'AmountOfSubscriptionPaid', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",),
@ -117,7 +117,7 @@ class ConferenceOrBoothAttendee extends CommonObject
'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
'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é'),),
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'default'=>0,'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validé', '9'=>'Annulé'),),
);
public $rowid;
public $ref;
@ -228,7 +228,23 @@ class ConferenceOrBoothAttendee extends CommonObject
*/
public function create(User $user, $notrigger = false)
{
return $this->createCommon($user, $notrigger);
global $langs;
if (!isValidEMail($this->email)) {
$langs->load("errors");
$this->errors[] = $langs->trans("ErrorBadEMail", $this->email);
return -1;
}
$result = $this->createCommon($user, $notrigger);
if ($result>0) {
$result =$this->fetch($result);
if ($result>0) {
$this->ref = $this->id;
$result = $this->update($user);
}
}
return $result;
}
/**
@ -382,6 +398,7 @@ class ConferenceOrBoothAttendee extends CommonObject
$sql = 'SELECT ';
$sql .= $this->getFieldList('t');
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm";
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
$sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
} else {
@ -391,7 +408,7 @@ class ConferenceOrBoothAttendee extends CommonObject
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
if ($key == 't.rowid') {
if ($key == 't.rowid' || $key == 't.fk_soc' || $key == 't.fk_project' || $key == 't.fk_actioncomm') {
$sqlwhere[] = $key.'='.$value;
} elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
$sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';

View File

@ -170,22 +170,6 @@ $title = $langs->trans("ConferenceOrBooth");
$help_url = '';
llxHeader('', $title, $help_url);
// Example : Adding jquery code
/*print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_myfunc()
{
jQuery("#myid").removeAttr(\'disabled\');
jQuery("#myid").attr(\'disabled\',\'disabled\');
}
init_myfunc();
jQuery("#mybutton").click(function() {
init_myfunc();
});
});
</script>';*/
// Part to create
if ($action == 'create') {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBooth")), '', 'object_'.$object->picto);

View File

@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("eventorganization", "other"));
@ -221,6 +221,12 @@ if (($id || $ref) && $action == 'edit') {
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
if ($confOrBooth->id > 0) {
print '<input type="hidden" name="conforboothid" value="'.$confOrBooth->id.'">';
}
if ($object->fk_actioncomm > 0) {
print '<input type="hidden" name="fk_actioncomm" value="'.$object->fk_actioncomm.'">';
}
if ($backtopage) {
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
}
@ -254,7 +260,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$res = $object->fetch_optionals();
$head = conferenceorboothattendeePrepareHead($object);
print dol_get_fiche_head($head, 'card', $langs->trans("ConferenceOrBoothAttendee"), -1, $object->picto);
print dol_get_fiche_head(array(), 'card', $langs->trans("ConferenceOrBoothAttendee"), -1, $object->picto);
$formconfirm = '';

View File

@ -219,8 +219,9 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.id = ef.fk_object)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
}
// Add table from hooks
$parameters = array();
@ -358,20 +359,6 @@ if ($conf_or_booth_id > 0) {
print dol_get_fiche_end();
}
// Example : Adding jquery code
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_myfunc()
{
jQuery("#myid").removeAttr(\'disabled\');
jQuery("#myid").attr(\'disabled\',\'disabled\');
}
init_myfunc();
jQuery("#mybutton").click(function() {
init_myfunc();
});
});
</script>';
$arrayofselected = is_array($toselect) ? $toselect : array();
@ -430,7 +417,7 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:''), '', $permissiontoadd);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);

View File

@ -55,7 +55,7 @@ function conferenceorboothPrepareHead($object)
} else {
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
$attendees=new ConferenceOrBoothAttendee($db);
$result = $attendees->fetchAll('', '', 0, 0, array('fk_actioncomm'=>$object->id));
$result = $attendees->fetchAll('', '', 0, 0, array('t.fk_actioncomm'=>$object->id));
if (!is_array($result) && $result<0) {
setEventMessages($attendees->error, $attendees->errors, 'errors');
} else {
@ -95,3 +95,25 @@ function conferenceorboothPrepareHead($object)
return $head;
}
/**
* Prepare array of tabs for ConferenceOrBoothAttendees
*
* @param ConferenceOrBoothAttendee $object ConferenceOrBoothAttendee
* @return array Array of tabs
*/
function conferenceorboothattendeePrepareHead($object)
{
global $db, $langs, $conf;
$langs->load("eventorganization");
$h = 0;
$head = array();
$head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_card.php", 1).'?id='.$object->id.'&conforboothid='.$object->fk_actioncomm;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
}

View File

@ -279,3 +279,48 @@ DELETE FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ti
-- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_graph_nb_tickets_type.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_graph_nb_tickets_type.php' AND entity = 1);
-- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_graph_new_vs_close_ticket.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_graph_new_vs_close_ticket.php' AND entity = 1);
CREATE TABLE llx_eventorganization_conferenceorboothattendee(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
ref varchar(128) NOT NULL,
fk_soc integer,
fk_project integer,
fk_actioncomm integer NOT NULL,
email varchar(100),
date_subscription datetime,
amount double DEFAULT NULL,
note_public text,
note_private text,
date_creation datetime NOT NULL,
tms timestamp,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
last_main_doc varchar(255),
import_key varchar(14),
model_pdf varchar(255),
status smallint NOT NULL
) ENGINE=innodb;
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_rowid (rowid);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_ref (ref);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_soc (fk_soc);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_project (fk_project);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_project FOREIGN KEY (fk_project) REFERENCES llx_projet(rowid);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_actioncomm (fk_actioncomm);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_actioncomm FOREIGN KEY (fk_actioncomm) REFERENCES llx_actioncomm(id);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_email (email);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT llx_eventorganization_conferenceorboothattendee_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_project, fk_actioncomm, email);
create table llx_eventorganization_conferenceorboothattendee_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;
ALTER TABLE llx_eventorganization_conferenceorboothattendee_extrafields ADD INDEX idx_conferenceorboothattendee_fk_object(fk_object);

View File

@ -28,6 +28,6 @@ ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT llx_e
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status);
-- END MODULEBUILDER INDEXES
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee_soc_proj_action(fk_soc, fk_project, fk_actioncomm);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_project, fk_actioncomm, email);