diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 79c4d4765be..a7a9fe4e9bb 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -168,6 +168,7 @@ if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$la if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember'); if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); +if ($conf->projet->enabled) $elementList['project']=$langs->trans('MailToProject'); $elementList['user']=$langs->trans('MailToUser'); $elementList['all'] =$langs->trans('VisibleEverywhere'); $elementList['none']=$langs->trans('VisibleNowhere'); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index bc36a5cbf94..d8d5b10a2b5 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -706,7 +706,6 @@ class Categorie extends CommonObject // Call trigger - $this->linkto=$obj; // Deprecated. Save object we want to link category to into category instance to provide information to trigger $this->context=array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger $result=$this->call_trigger('CATEGORY_LINK',$user); if ($result < 0) { $error++; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index a9dec780ba8..755d3ff4bf0 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -675,7 +675,8 @@ class Contrat extends CommonObject } /** - * Load lines array into this->lines + * Load lines array into this->lines. + * This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed * * @return ContratLigne[] Return array of contract lines */ diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 9f5224a71d3..8f7ee1287fe 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -385,7 +385,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($mailfile->error) { - setEventMessage($mailfile->error, 'errors'); + setEventMessages($mailfile->error, $mailfile->errors, 'errors'); $action='presend'; } else diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 0caf056eab6..47af9ba4ae0 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -753,7 +753,7 @@ class CMailFile $domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; $selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; $signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector); - $this->message->attachSigner($signer); + $this->message->attachSigner($signer->ignoreHeader('Return-Path')); } if (! empty($conf->global->MAIN_MAIL_DEBUG)) { diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 2813a0d46b1..5cb7d3e6882 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,7 @@ /** - * \class DiscountAbsolute - * \brief Class to manage absolute discounts + * Class to manage absolute discounts */ class DiscountAbsolute { @@ -231,7 +230,7 @@ class DiscountAbsolute return -1; } } - + // Check if we can remove the discount if ($this->fk_invoice_supplier_source) { @@ -241,7 +240,7 @@ class DiscountAbsolute $sql.=" OR fk_invoice_supplier IS NOT NULL)"; // Not used as credit note and not used as deposit $sql.=" AND fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; //$sql.=" AND rowid != ".$this->id; - + dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -298,7 +297,7 @@ class DiscountAbsolute } } elseif($this->fk_invoice_supplier_source) { - + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; $sql.=" set paye=0, fk_statut=1"; $sql.=" WHERE (type = 2 or type = 3) AND rowid=".$this->fk_invoice_supplier_source; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 466faba295e..d53072efe0a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6444,6 +6444,11 @@ class Form else $morehtmlstatus=$hookmanager->resPrint; if ($morehtmlstatus) $ret.='
'.$morehtmlstatus.'
'; + $parameters = array(); + $reshook = $hookmanager->executeHooks('moreHtmlRef', $parameters, $object); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $morehtmlref.=$hookmanager->resPrint; + elseif ($reshook > 0) $morehtmlref=$hookmanager->resPrint; + // Left part of banner if ($morehtmlleft) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index aee9ed61f62..b71ba047516 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1298,6 +1298,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $maxvisiblephotos=1; $showimage=1; + $entity=(empty($object->entity)?$conf->entity:$object->entity); $showbarcode=empty($conf->barcode->enabled)?0:($object->barcode?1:0); if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; $modulepart='unknown'; @@ -1324,10 +1325,10 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if ($object->element == 'product') { $width=80; $cssclass='photoref'; - $showimage=$object->is_photo_available($conf->product->multidir_output[$object->entity]); + $showimage=$object->is_photo_available($conf->product->multidir_output[$entity]); $maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5); if ($conf->browser->phone) $maxvisiblephotos=1; - if ($showimage) $morehtmlleft.='
'.$object->show_photos('product', $conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'
'; + if ($showimage) $morehtmlleft.='
'.$object->show_photos('product', $conf->product->multidir_output[$entity],'small',$maxvisiblephotos,0,0,0,$width,0).'
'; else { if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) { @@ -1343,10 +1344,10 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r elseif ($object->element == 'ticketsup') { $width=80; $cssclass='photoref'; - $showimage=$object->is_photo_available($conf->ticketsup->dir_output.'/'.$object->track_id); + $showimage=$object->is_photo_available($conf->ticketsup->multidir_output[$entity].'/'.$object->track_id); $maxvisiblephotos=(isset($conf->global->TICKETSUP_MAX_VISIBLE_PHOTO)?$conf->global->TICKETSUP_MAX_VISIBLE_PHOTO:2); if ($conf->browser->phone) $maxvisiblephotos=1; - if ($showimage) $morehtmlleft.='
'.$object->show_photos('ticketsup', $conf->ticketsup->dir_output,'small',$maxvisiblephotos,0,0,0,$width,0).'
'; + if ($showimage) $morehtmlleft.='
'.$object->show_photos('ticketsup', $conf->ticketsup->multidir_output[$entity],'small',$maxvisiblephotos,0,0,0,$width,0).'
'; else { if (!empty($conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) { @@ -1370,7 +1371,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice', 'expensereport')) && class_exists("Imagick")) { $objectref = dol_sanitizeFileName($object->ref); - $dir_output = $conf->$modulepart->dir_output . "/"; + $dir_output = $conf->$modulepart->multidir_output[$entity] . "/"; if (in_array($modulepart, array('invoice_supplier', 'supplier_invoice'))) { $subdir = get_exdir($object->id, 2, 0, 0, $object, $modulepart).$objectref; // the objectref dir is not include into get_exdir when used with level=2, so we add it here diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 8e2cba43097..1fec9c1b024 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -127,15 +127,18 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir=' { $i++; $texttoinsert.= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',"; - $texttoinsert.= " 'visible'=>".($val['visible']!=''?$val['visible']:-1).","; $texttoinsert.= " 'enabled'=>".($val['enabled']!=''?$val['enabled']:1).","; + $texttoinsert.= " 'visible'=>".($val['visible']!=''?$val['visible']:-1).","; $texttoinsert.= " 'position'=>".($val['position']!=''?$val['position']:50).","; $texttoinsert.= " 'notnull'=>".($val['notnull']!=''?$val['notnull']:-1).","; - if ($val['index']) $texttoinsert.= " 'index'=>".$val['index'].","; - if ($val['searchall']) $texttoinsert.= " 'searchall'=>".$val['searchall'].","; - if ($val['comment']) $texttoinsert.= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\","; // addslashes is escape for PHP - if ($val['isameasure']) $texttoinsert.= " 'isameasure'=>'".$val['isameasure']."',"; - if ($val['help']) $texttoinsert.= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\","; // addslashes is escape for PHP + if ($val['default']) $texttoinsert.= " 'default'=>'".$val['default']."',"; + if ($val['index']) $texttoinsert.= " 'index'=>".$val['index'].","; + if ($val['searchall']) $texttoinsert.= " 'searchall'=>".$val['searchall'].","; + if ($val['isameasure']) $texttoinsert.= " 'isameasure'=>'".$val['isameasure']."',"; + if ($val['foreignkey']) $texttoinsert.= " 'foreignkey'=>'".$val['foreignkey']."',"; + if ($val['help']) $texttoinsert.= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\","; + if ($val['comment']) $texttoinsert.= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\","; + if ($val['showoncombobox']) $texttoinsert.= " 'showoncombobox'=>'".$val['showoncombobox']."',"; if ($val['arrayofkeyval']) { $texttoinsert.= " 'arrayofkeyval'=>array("; @@ -301,11 +304,20 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', foreach($object->fields as $key => $val) { $i++; - if ($val['index']) + if (! empty($val['index'])) { $texttoinsert.= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");"; $texttoinsert.= "\n"; } + if (! empty($val['foreignkey'])) + { + $tmp=explode('.',$val['foreignkey']); + if (! empty($tmp[0]) && ! empty($tmp[1])) + { + $texttoinsert.= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES ".$tmp[0]."(".$tmp[1].");"; + $texttoinsert.= "\n"; + } + } } } $texttoinsert.= '-- END MODULEBUILDER INDEXES'; diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index d4ffc513521..a6473eaeb8e 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -591,6 +591,7 @@ class ImportCsv extends ModeleImports if (!empty($updatekeys)) { // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) + if (empty($lastinsertid)) { $sqlSelect = 'SELECT rowid FROM '.$tablename; @@ -626,6 +627,34 @@ class ImportCsv extends ModeleImports $this->errors[$error]['type']='SQL'; $error++; } + } else { + // We have a last INSERT ID. Check if we have a row referencing this foreign key. + // This is required when updating table with some extrafields. When inserting a record in parent table, we can make + // a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record + // may already exists. So we rescan the extrafield table to be know if record exists or not for the rowid. + $sqlSelect = 'SELECT rowid FROM '.$tablename; + + if(empty($keyfield)) $keyfield = 'rowid'; + $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; + + $resql=$this->db->query($sqlSelect); + if($resql) { + $res = $this->db->fetch_object($resql); + if($resql->num_rows == 1) { + // We have a row referencing this last foreign key, continue with UPDATE. + } else { + // No record found referencing this last foreign key, + // force $lastinsertid to 0 so we INSERT below. + $lastinsertid = 0; + } + } + else + { + //print 'E'; + $this->errors[$error]['lib']=$this->db->lasterror(); + $this->errors[$error]['type']='SQL'; + $error++; + } } if (!empty($lastinsertid)) { diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 214ce91b032..7f222f523ca 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -651,6 +651,34 @@ class ImportXlsx extends ModeleImports $this->errors[$error]['type']='SQL'; $error++; } + } else { + // We have a last INSERT ID. Check if we have a row referencing this foreign key. + // This is required when updating table with some extrafields. When inserting a record in parent table, we can make + // a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record + // may already exists. So we rescan the extrafield table to be know if record exists or not for the rowid. + $sqlSelect = 'SELECT rowid FROM '.$tablename; + + if(empty($keyfield)) $keyfield = 'rowid'; + $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; + + $resql=$this->db->query($sqlSelect); + if($resql) { + $res = $this->db->fetch_object($resql); + if($resql->num_rows == 1) { + // We have a row referencing this last foreign key, continue with UPDATE. + } else { + // No record found referencing this last foreign key, + // force $lastinsertid to 0 so we INSERT below. + $lastinsertid = 0; + } + } + else + { + //print 'E'; + $this->errors[$error]['lib']=$this->db->lasterror(); + $this->errors[$error]['type']='SQL'; + $error++; + } } if (!empty($lastinsertid)) { diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 8f770dcca46..6b8f24a2000 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -138,14 +138,15 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; // Show date range if ($line->element == 'facturedetrec') { - if ($line->date_start_fill || $line->date_end_fill) echo '

'; + if ($line->date_start_fill || $line->date_end_fill) echo '
'; if ($line->date_start_fill) echo $langs->trans('AutoFillDateFromShort').': '.yn($line->date_start_fill); if ($line->date_start_fill && $line->date_end_fill) echo ' - '; if ($line->date_end_fill) echo $langs->trans('AutoFillDateToShort').': '.yn($line->date_end_fill); if ($line->date_start_fill || $line->date_end_fill) echo '
'; } else { - echo get_date_range($line->date_start, $line->date_end, $format); + echo '
'.get_date_range($line->date_start, $line->date_end, $format).'
'; + //echo get_date_range($line->date_start, $line->date_end, $format); } // Add description in form diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index a0fbe09405c..ecf57316c89 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -56,10 +56,10 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // We add subscription if we change category (new category may means more mailing-list to subscribe) - if (is_object($object->linkto) && method_exists($object->linkto, 'add_to_abo') && $object->linkto->add_to_abo() < 0) + if (is_object($object->context['linkto']) && method_exists($object->context['linkto'], 'add_to_abo') && $object->context['linkto']->add_to_abo() < 0) { - $this->error=$object->linkto->error; - $this->errors=$object->linkto->errors; + $this->error=$object->context['linkto']->error; + $this->errors=$object->context['linkto']->errors; $return=-1; } else diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 1bb68fe5cd9..b4df819b976 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -517,7 +517,7 @@ if ($num > 0) print ''; if ($user->rights->cron->create) { - print "rowid."&action=edit".($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param."&backtourl=".urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:''))."\" title=\"".dol_escape_htmltag($langs->trans('Edit'))."\">".img_picto($langs->trans('Edit'),'edit')."  "; + print "rowid."&action=edit".($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param."&backtourl=".urlencode($_SERVER["PHP_SELF"].'?'.$param.($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:''))."\" title=\"".dol_escape_htmltag($langs->trans('Edit'))."\">".img_picto($langs->trans('Edit'),'edit')."  "; } if ($user->rights->cron->delete) { diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 04c039cfbb1..43e70c03013 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -736,7 +736,7 @@ if ($id > 0 || ! empty($ref)) { // List of lines already dispatched $sql = "SELECT p.ref, p.label,"; $sql .= " e.rowid as warehouse_id, e.ref as entrepot,"; - $sql .= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status"; + $sql .= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.datec"; $sql .= " FROM " . MAIN_DB_PREFIX . "product as p,"; $sql .= " " . MAIN_DB_PREFIX . "commande_fournisseur_dispatch as cfd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entrepot as e ON cfd.fk_entrepot = e.rowid"; @@ -770,6 +770,7 @@ if ($id > 0 || ! empty($ref)) { print '' . $langs->trans("Comment") . ''; if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) print '' . $langs->trans("Status") . ''; + print '' . $langs->trans("Date") . ''; print "\n"; $var = false; @@ -841,7 +842,9 @@ if ($id > 0 || ! empty($ref)) { } print ''; } - + // date + print '' . dol_print_date($objp->datec) . ''; + print "\n"; $i ++; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index be46a1e15c8..655e5d46884 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1729,6 +1729,7 @@ MailToSendContract=To send a contract MailToThirdparty=To send email from third party page MailToMember=To send email from member page MailToUser=To send email from user page +MailToProject= To send email from project page ByDefaultInList=Show by default on list view YouUseLastStableVersion=You use the latest stable version TitleExampleForMajorRelease=Example of message you can use to announce this major release (feel free to use it on your web sites) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 4e1f755894b..5cc94c39309 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -226,3 +226,4 @@ AllowCommentOnProject=Allow user comments on projects DontHavePermissionForCloseProject=You do not have permissions to close the project %s DontHaveTheValidateStatus=The project %s must be open to be closed RecordsClosed=%s project(s) closed +SendProjectRef=About project %s diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 376c9bcfc38..b6aa06cb273 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -60,6 +60,7 @@ class MyObject extends CommonObject * 'enabled' is a condition when the field must be managed. * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) * 'index' if we want an index in database. * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). * 'position' is the sort order of field. @@ -67,8 +68,8 @@ class MyObject extends CommonObject * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). * 'help' is a string visible as a tooltip on field * 'comment' is not used. You can store here any text of your choice. It is not used by application. - * 'default' is a default value for creation (can still be replaced by the global setup of default values) - * 'showoncombobox' if field must be shown into the label of combobox + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") */ // BEGIN MODULEBUILDER PROPERTIES @@ -79,16 +80,16 @@ class MyObject extends CommonObject 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text'), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text'), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>0, 'help'=>'LinkToThirparty'), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), 'description' =>array('type'=>'text', 'label'=>'Descrption', 'enabled'=>1, 'visible'=>0, 'position'=>60), 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), diff --git a/htdocs/modulebuilder/template/sql/llx_mymodule_myobject.key.sql b/htdocs/modulebuilder/template/sql/llx_mymodule_myobject.key.sql index 6e301744fa6..339939ba83f 100644 --- a/htdocs/modulebuilder/template/sql/llx_mymodule_myobject.key.sql +++ b/htdocs/modulebuilder/template/sql/llx_mymodule_myobject.key.sql @@ -18,7 +18,7 @@ ALTER TABLE llx_mymodule_myobject ADD INDEX idx_fieldobject (fieldobject); -- END MODULEBUILDER INDEXES ---ALTER TABLE llx_mymodule_myobject ADD UNIQUE INDEX uk_mymodule_myobject_fieldxyz(fieldx, fieldy); +--ALTER TABLE llx_mymodule_myobject ADD UNIQUE INDEX uk_mymodule_myobject_fieldxy(fieldx, fieldy); ---ALTER TABLE llx_mymodule_myobject ADD CONSTRAINT llx_mymodule_myobject_field_id FOREIGN KEY (fk_field) REFERENCES llx_myotherobject(rowid); +--ALTER TABLE llx_mymodule_myobject ADD CONSTRAINT llx_mymodule_myobject_fk_field FOREIGN KEY (fk_field) REFERENCES llx_mymodule_myotherobject(rowid); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index c5cfb9b3756..466bb8729c2 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -446,6 +446,13 @@ if (empty($reshook)) $comefromclone=true; } } + + // Actions to send emails + $trigger_name='PROJECT_SENTBYMAIL'; + $paramname='id'; + $autocopy='MAIN_MAIL_AUTOCOPY_ORDER_TO'; // used to know the automatic BCC to add + $trackid='proj'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -1064,7 +1071,7 @@ elseif ($object->id > 0) // modified by hook if (empty($reshook)) { - if ($action != "edit" ) + if ($action != "edit" && $action != 'presend' ) { // Create event @@ -1075,6 +1082,12 @@ elseif ($object->id > 0) print ''; }*/ + // Send + if ($object->statut != 2) + { + print ''; + } + // Modify if ($object->statut != 2 && $user->rights->projet->creer) { @@ -1212,6 +1225,10 @@ elseif ($object->id > 0) print "
"; + if (GETPOST('modelselected')) { + $action = 'presend'; + } + if ($action != 'presend') { print '
'; @@ -1244,6 +1261,14 @@ elseif ($object->id > 0) print '
'; } + // Presend form + $modelmail='project'; + $defaulttopic='SendProjectRef'; + $diroutput = $conf->projet->dir_output; + $trackid = 'proj'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + // Hook to add more things on page $parameters=array(); $reshook=$hookmanager->executeHooks('mainCardTabAddMore',$parameters,$object,$action); // Note that $action and $object may have been modified by hook