From be60e66d626420731ffa017d1d8696695e0034a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 16:29:33 +0200 Subject: [PATCH 1/7] Uniformsize code/options --- htdocs/compta/facture/card.php | 72 +++++++++++++++++------------- htdocs/theme/eldy/img/stcomm0.png | Bin 914 -> 929 bytes 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 2535d8e7442..940ada5e04b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -604,27 +604,30 @@ if (empty($reshook)) $ventilExportCompta = $object->getVentilExportCompta(); // On verifie si aucun paiement n'a ete effectue - if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) + if ($ventilExportCompta == 0) { - $result=$object->set_draft($user, $idwarehouse); - if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); - - - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records + $result=$object->set_draft($user, $idwarehouse); + if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } } } } @@ -1436,7 +1439,7 @@ if (empty($reshook)) $object->situation_counter = $object->situation_counter + 1; $id = $object->createFromCurrent($user); - if ($id <= 0) + if ($id <= 0) { $mesg = $object->error; } @@ -4115,28 +4118,35 @@ else if ($id > 0 || ! empty($ref)) $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { // Editer une facture deja validee, sans paiement effectue et pas exporte en compta - if ($object->statut == 1) + if ($object->statut == Facture::STATUS_VALIDATED) { // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees $ventilExportCompta = $object->getVentilExportCompta(); - if ($resteapayer == $object->total_ttc && empty($object->paye) && $ventilExportCompta == 0) + if ($ventilExportCompta == 0) { - if (! $objectidnext && $object->is_last_in_cycle()) + if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) + if (! $objectidnext && $object->is_last_in_cycle()) { - print '
' . $langs->trans('Modify') . '
'; + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) + { + print '
' . $langs->trans('Modify') . '
'; + } else { + print '
' . $langs->trans('Modify') . '
'; + } + } else if (!$object->is_last_in_cycle()) { + print '
' . $langs->trans('Modify') . '
'; } else { - print '
' . $langs->trans('Modify') . '
'; + print '
' . $langs->trans('Modify') . '
'; } - } else if (!$object->is_last_in_cycle()) { - print '
' . $langs->trans('Modify') . '
'; - } else { - print '
' . $langs->trans('Modify') . '
'; } } + else + { + print '
' . $langs->trans('Modify') . '
'; + } } $discount = new DiscountAbsolute($db); @@ -4158,7 +4168,7 @@ else if ($id > 0 || ! empty($ref)) } // Validate - if ($object->statut == 0 && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { + if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate))) { diff --git a/htdocs/theme/eldy/img/stcomm0.png b/htdocs/theme/eldy/img/stcomm0.png index b6c11d4569a5c96c92fb645c2479f82ecb4da690..1220cf8113e453c82a2fdb2d639eb086aef570e4 100644 GIT binary patch delta 864 zcmV-m1E2ho2cZX$B#|*Kf8hxm3lk$$84qay00S;bL_t(I%Y~C&Xj^3*#-I0`B%~+J zhe?{`)JSQ&NeRpFLfFv2aNrozY4Kwh!-0Yq4zVbT1BG48E7ythV$NRGFFM95bHW7I zV$j(QbQf)1x^~SdIV5emHpVu|N%Efe{l8ww2J`c|{KNBuKRiE%fB(s`W8e6tq;yAz z=S9xN{(8Or8t2YeCr=(!0O0z!;_>6(d4-^i*Q>wK-yeU>G=mS6%NuNZy71K6TKii7 z_TK=fPGvPI$zY5m#gmqSiA=?GV)_wDYYjQ zGM+ch(B6T8ggX}Ve?!+9q*SO>Y`EPnY~5=5=H^N-0eA-h*y!k$`-s%DhT$IU>+8yN zcZY(e8Gx>9005;FI43MDl;QV#A%w!|)04C1@^4R^IrC~!BcgOT?E7HXt_SyR+twX4 z%^-AL17i$~F+`(L3=a>ZRI0+`al!4@kV+-{iPYfW;D?$fe+1oT47VJIShZ?nX{mx@ zv5H2c4Iw1XojZ>cC*Frr3Q`grhtSv8<@5PE9w(xxMnp@+Vs%nV5{X0rk%$4?=9rpV z#M!go>C&`1BT&2B+`jw zGK>QU_9K&de-6F9I}wkEKm>3uK%~IAG%Rb)r39RLhUsi!pnIC5lf%eMJvxm-yS{rRg960@@<)axze zawWQU?UuE$Q2f$yoRMtyXz?yUO4TTps^=}M@^CQdbG6$7`TROKm$0k~rlxN2`T5dV zrLy@sk-D7C9u)wf-vL~`I!@{IleTU1%$6;&c(duCR%_$ZrC)0k6Ejx|h1)~5TJvK- zdKO&;9FI;$Y{hy>`e?1&J^vRw; qz!+_{_!k=+^|A5s*JuAr_dfvX^`3}Qvc+ov0000yXApqp$&s3;T^x~RK~7#F2x z75`{A6|GP~GBCstDVjw(G)=-Zq2#O+SO&g!MS+3+3dW{dGO8D)JX*Z#=ikCT=+381RV~C^;1JbeJ|K{{K-ni zWlKw&uk7q}egNS8jo{+Nye1`CjIpORjlI*`8-MQ5p{FwGbOcHPy3XJ@)rqaG`iB6D zj}c5y|J0|HI+jRSuiJLw`0#Kh)Y}_>g|0J5sZgtV2!#yn-)~25-!8ui;C%pKGc!Lw zL8M-@tkC%2V9(+H{zTliW6*UC0HBlt=Y+Mj3Zl_4giyG2DOadeetYT4mA6V75sfC3 zk&llYIdJ0O!Tz{y#~*?LKuU!mAe75>n5KbHNW;iTc8ExgkB@(%X+qF_#;_iL1jOof z4;vdbluC7Y9tY8b>+Lp&QVLQMf`BkM*b|9Fx?Uurv_?c5rBXd7C5cQXhE&Re=W#47 z6fr+vM77#Lz1{)<1c8JQ65ZWl3=E{64+1f&U%&pjJbLtG!}rCB;bA*wSte4cZe+7b zxUP@c*#e5i3i|pIAObiSd!I>v%W-xLV^8PO=4SPmd-vRIHk*J_0Kkw=cVleq06edQ zWHJg(V`#NHXtx6Z3`(h2H2^q!_PFnP{EOw~vLt$-RR{^!Z6lM3V_+Z+)6^k^1m^-b zZ*B&;+|p{Z>A&|d2fMr8T(P+Q>&Qs|SWizBjYbECq3>xYG@Cw_m&>$&xVY}Dt(CqG zf?ztIKUXpyv8z=s*S~d~+B5NZ#OQPcOw$185{^^D!omt)T`ga()poxmQuF!zIq_H$ ziAcC^XZFU8^;7%yrAB=}K&!sD#y&Yi6~Pl@QeYuDbb{!{7LUl*rOe|9Vuvu1psf91N(%U7?SDg0O6 Z{{UZ^ppoHEEv5hf002ovPDHLkV1jRSpN{|l From f1f4a2fb445ea01be6adf5828c3a25f36411283d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 17:40:14 +0200 Subject: [PATCH 2/7] Add email template to send SEPA mandate --- htdocs/core/lib/functions.lib.php | 7 ++++++- htdocs/install/mysql/data/llx_c_email_templates.sql | 4 +++- htdocs/langs/en_US/banks.lang | 4 +++- htdocs/langs/en_US/main.lang | 3 +++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ba8e9f4d085..a826b16d266 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5234,7 +5234,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob '__MYCOMPANY_PROFID5__' => $mysoc->idprof5, '__MYCOMPANY_PROFID6__' => $mysoc->idprof6, '__MYCOMPANY_CAPITAL__' => $mysoc->capital, - '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id + '__MYCOMPANY_FULLADDRESS__' => $mysoc->getFullAddress(1), + '__MYCOMPANY_ADDRESS__' => $mysoc->address, + '__MYCOMPANY_ZIP__' => $mysoc->zip, + '__MYCOMPANY_TOWN__' => $mysoc->town, + '__MYCOMPANY_COUNTRY__' => $mysoc->country, + '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id )); } if (($onlykey || is_object($object)) && (empty($exclude) || ! in_array('object', $exclude))) diff --git a/htdocs/install/mysql/data/llx_c_email_templates.sql b/htdocs/install/mysql/data/llx_c_email_templates.sql index b3bb3292ba6..240be5fcbe6 100644 --- a/htdocs/install/mysql/data/llx_c_email_templates.sql +++ b/htdocs/install/mysql/data/llx_c_email_templates.sql @@ -20,4 +20,6 @@ -- de l'install et tous les sigles '--' sont supprimés. -- -INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'member',null,0,null,null,'(SendAnEMailToMember)',1,1,'__(CardContent)__','__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__',null); +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'member',null,0,null,null,'(SendAnEMailToMember)',1,1,'__(CardContent)__','__(Hello)__

__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__',null); + +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'thirdparty',null,0,null,null,'(YourSEPAMandate)',1,1,'__(YourSEPAMandate)__','__(Hello)__

__(PleaseFindYourSEPAMandate)__
\n__MYCOMPANY_NAME__
\n__MYCOMPANY_FULLADDRESS__',null); diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index caed4498f3b..3ca1ac9ce5c 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -157,4 +157,6 @@ NewVariousPayment=New miscellaneous payments VariousPayment=Miscellaneous payments VariousPayments=Miscellaneous payments ShowVariousPayment=Show miscellaneous payments -AddVariousPayment=Add miscellaneous payments \ No newline at end of file +AddVariousPayment=Add miscellaneous payments +YourSEPAMandate=Your SEPA mandate +PleaseFindYourSEPAMandate=This is your SEPA mandate. Thanks to return it signed (scan of the signed document) or sent by mail to diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 93616b6151c..ba6b43fb9fc 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -814,6 +814,9 @@ Websites=Web sites Events=Events EMailTemplates=Emails templates FileNotShared=File not shared to exernal public +Hello=Hello +Goodbye=Goodbye +Sincerely=Sincerely # Week day Monday=Monday Tuesday=Tuesday From 8242469e40af90d2c873d4acc91665bb94621ffd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 18:16:28 +0200 Subject: [PATCH 3/7] FIX The unique index on email templates can work now. --- htdocs/admin/mails_templates.php | 6 +++--- htdocs/core/lib/functions.lib.php | 12 +++++++++--- htdocs/install/mysql/data/llx_c_email_templates.sql | 5 +++-- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 6 +++++- .../install/mysql/tables/llx_c_email_templates.sql | 3 ++- htdocs/langs/en_US/banks.lang | 2 +- htdocs/langs/en_US/main.lang | 4 +--- 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 2f440f9f873..755440a47fd 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -177,7 +177,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'); -$elementList['all']=$langs->trans('VisibleEverywhere'); +$elementList['all'] =$langs->trans('VisibleEverywhere'); $elementList['none']=$langs->trans('VisibleNowhere'); @@ -295,7 +295,7 @@ if (empty($reshook)) if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]=''; if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0'; if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1'; - if ($_POST[$keycode] == '' || ($keycode == 'langcode' && empty($_POST[$keycode]))) $sql.="null"; // For vat, we want/accept code = '' + if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } @@ -485,7 +485,7 @@ if (! $user->admin) } if (empty($conf->global->MAIN_MULTILANGS)) { - $sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL)"; + $sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL OR lang = '')"; } if ($search_label) $sql.=natural_search('label', $search_label); if ($search_type_template != '' && $search_type_template != '-1') $sql.=natural_search('type_template', $search_type_template); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a826b16d266..c252df5070e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5234,7 +5234,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob '__MYCOMPANY_PROFID5__' => $mysoc->idprof5, '__MYCOMPANY_PROFID6__' => $mysoc->idprof6, '__MYCOMPANY_CAPITAL__' => $mysoc->capital, - '__MYCOMPANY_FULLADDRESS__' => $mysoc->getFullAddress(1), + '__MYCOMPANY_FULLADDRESS__' => $mysoc->getFullAddress(1, ', '), '__MYCOMPANY_ADDRESS__' => $mysoc->address, '__MYCOMPANY_ZIP__' => $mysoc->zip, '__MYCOMPANY_TOWN__' => $mysoc->town, @@ -5395,8 +5395,14 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob '__USER_FIRSTNAME__' => (string) $user->firstname, '__USER_FULLNAME__' => (string) $user->getFullName($outputlangs), '__USER_SUPERVISOR_ID__' => (string) $user->fk_user, - '__SIGNATURE__' => (string) (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : '') - )); + '__USER_SIGNATURE__' => (string) (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : '') + ) + ); + // For backward compatibility + if ($onlykey != 2) + { + $substitutionarray['__SIGNATURE__'] = (string) (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : ''); + } } if (! empty($conf->multicompany->enabled)) { diff --git a/htdocs/install/mysql/data/llx_c_email_templates.sql b/htdocs/install/mysql/data/llx_c_email_templates.sql index 240be5fcbe6..bfa183781c7 100644 --- a/htdocs/install/mysql/data/llx_c_email_templates.sql +++ b/htdocs/install/mysql/data/llx_c_email_templates.sql @@ -20,6 +20,7 @@ -- de l'install et tous les sigles '--' sont supprimés. -- -INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'member',null,0,null,null,'(SendAnEMailToMember)',1,1,'__(CardContent)__','__(Hello)__

__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__',null); +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'adherent','member','',0,null,null,'(SendAnEMailToMember)',1,1,1,'__(CardContent)__','__(Hello)__,

\n\n__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__

\n__(Sincerely)__
__USER_SIGNATURE__',null); +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'banque','thirdparty','',0,null,null,'(YourSEPAMandate)',1,1,0,'__(YourSEPAMandate)__','__(Hello)__,

\n\n__(FindYourSEPAMandate)__ :
\n__MYCOMPANY_NAME__
\n__MYCOMPANY_FULLADDRESS__

\n__(Sincerely)__
\n__USER_SIGNATURE__',null); + -INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'thirdparty',null,0,null,null,'(YourSEPAMandate)',1,1,'__(YourSEPAMandate)__','__(Hello)__

__(PleaseFindYourSEPAMandate)__
\n__MYCOMPANY_NAME__
\n__MYCOMPANY_FULLADDRESS__',null); diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 0d2a6a7baed..b2df01afe51 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -70,8 +70,12 @@ ALTER TABLE llx_contrat MODIFY COLUMN ref_ext varchar(50); UPDATE llx_c_email_templates SET position = 0 WHERE position IS NULL; +UPDATE llx_c_email_templates SET lang = '' WHERE lang IS NULL; -INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,active,topic,content,content_lines) VALUES (0,null,'member',null,0,null,null,'(SendAnEMailToMember)',1,1,'__(CardContent)__','__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__',null); +ALTER TABLE llx_c_email_templates ADD COLUMN enabled varchar(255) DEFAULT '1'; + +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'adherent','member','',0,null,null,'(SendAnEMailToMember)',1,1,1,'__(CardContent)__','__(Hello)__,

\n\n__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__

\n__(Sincerely)__
__USER_SIGNATURE__',null); +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'banque','thirdparty','',0,null,null,'(YourSEPAMandate)',1,1,0,'__(YourSEPAMandate)__','__(Hello)__,

\n\n__(FindYourSEPAMandate)__ :
\n__MYCOMPANY_NAME__
\n__MYCOMPANY_FULLADDRESS__

\n__(Sincerely)__
\n__USER_SIGNATURE__',null); INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 1, 'VENTES', 'Income of products/services', 'Exemple: 7xxxxx', 0, 0, '', '10', 1, 1); INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 2, 'DEPENSES', 'Expenses of products/services', 'Exemple: 6xxxxx', 0, 0, '', '20', 1, 1); diff --git a/htdocs/install/mysql/tables/llx_c_email_templates.sql b/htdocs/install/mysql/tables/llx_c_email_templates.sql index 9d82d37768a..69cbc186ebd 100644 --- a/htdocs/install/mysql/tables/llx_c_email_templates.sql +++ b/htdocs/install/mysql/tables/llx_c_email_templates.sql @@ -23,13 +23,14 @@ create table llx_c_email_templates entity integer DEFAULT 1 NOT NULL, -- multi company id module varchar(32), -- Nom du module en rapport avec le modele type_template varchar(32), -- template for which type of email (send invoice by email, send order, ...) - lang varchar(6), + lang varchar(6) DEFAULT '', -- We use a default to '' so the unique index that include this field will work private smallint DEFAULT 0 NOT NULL, -- Template public or private fk_user integer, -- Id user owner if template is private, or null datec datetime, tms timestamp, label varchar(255), -- Label of predefined email position smallint, -- Position + enabled varchar(255) DEFAULT '1', -- Condition to have this module visible active tinyint DEFAULT 1 NOT NULL, topic text, -- Predefined topic content text, -- Predefined text diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 3ca1ac9ce5c..d45c0c15c1c 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -159,4 +159,4 @@ VariousPayments=Miscellaneous payments ShowVariousPayment=Show miscellaneous payments AddVariousPayment=Add miscellaneous payments YourSEPAMandate=Your SEPA mandate -PleaseFindYourSEPAMandate=This is your SEPA mandate. Thanks to return it signed (scan of the signed document) or sent by mail to +FindYourSEPAMandate=This is your SEPA mandate to authorize our company to make direct debit order to your bank. Thanks to return it signed (scan of the signed document) or sent it by mail to diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index ba6b43fb9fc..a21b2a9d355 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -770,6 +770,7 @@ Genderwoman=Woman ViewList=List view Mandatory=Mandatory Hello=Hello +GoodBye=GoodBye Sincerely=Sincerely DeleteLine=Delete line ConfirmDeleteLine=Are you sure you want to delete this line? @@ -814,9 +815,6 @@ Websites=Web sites Events=Events EMailTemplates=Emails templates FileNotShared=File not shared to exernal public -Hello=Hello -Goodbye=Goodbye -Sincerely=Sincerely # Week day Monday=Monday Tuesday=Tuesday From 7a0b8c39643c37d9b3582192ef5a125d8b1f63d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 18:23:49 +0200 Subject: [PATCH 4/7] Translation --- htdocs/langs/en_US/main.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a21b2a9d355..bfcbb5a2010 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -262,6 +262,7 @@ DateBuild=Report build date DatePayment=Date of payment DateApprove=Approving date DateApprove2=Approving date (second approval) +RegistrationDate=Registration date UserCreation=Creation user UserModification=Modification user UserCreationShort=Creat. user From fdc1aa2a03e26cb45da0b356297934c6a957b59e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 19:56:03 +0200 Subject: [PATCH 5/7] NEW Move contacts of a thirdparty on tab Contacts/Addresses --- htdocs/contact/card.php | 4 +- htdocs/core/class/html.formmail.class.php | 8 +- htdocs/core/lib/company.lib.php | 13 +- htdocs/core/lib/order.lib.php | 20 +- htdocs/core/tpl/card_presend.tpl.php | 42 +++-- htdocs/langs/en_US/other.lang | 4 +- htdocs/societe/card.php | 176 ++++++++--------- htdocs/societe/class/societe.class.php | 5 + htdocs/societe/contact.php | 218 ++++++++++++++++++++++ 9 files changed, 353 insertions(+), 137 deletions(-) create mode 100644 htdocs/societe/contact.php diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 2d6f728b502..43b9b7e4760 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -541,7 +541,7 @@ else { print ''; print ''; - print $objsoc->getNomUrl(1); + print $objsoc->getNomUrl(1, 'contact'); print ''; print ''; print ''; @@ -1063,7 +1063,7 @@ else $objsoc->fetch($object->socid); // Thirdparty $morehtmlref.=$langs->trans('ThirdParty') . ' : '; - if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1); + if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1, 'contact'); else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany"); } $morehtmlref.=''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index e1df1156239..0621e1d21f4 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -301,7 +301,7 @@ class FormMail extends Form { $model_id=$this->param["models_id"]; } - $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); + $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, ($model_id ? $model_id : -1)); // we set -1 if model_id empty } //var_dump($this->param["models"]); //var_dump($model_id); @@ -914,7 +914,7 @@ class FormMail extends Form * @param string $type_template Get message for type=$type_template, type='all' also included. * @param string $user Use template public or limited to this user * @param Translate $outputlangs Output lang object - * @param int $id Id template to find + * @param int $id Id of template to find, or -1 for first found with position = 0, or 0 for all * @param int $active 1=Only active template, 0=Only disabled, -1=All * @return array array('topic'=>,'content'=>,..) */ @@ -929,8 +929,10 @@ class FormMail extends Form $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned if ($active >= 0) $sql.=" AND active = ".$active; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; - if (!empty($id)) $sql.= " AND rowid=".$id; + if ($id > 0) $sql.= " AND rowid=".$id; + if ($id == -1) $sql.= " AND position=0"; $sql.= $db->order("position,lang,label","ASC"); + if ($id == -1) $sql.= $db->plimit(1); //print $sql; $resql = $db->query($sql); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 159e7a6435a..54c5abfda93 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -48,6 +48,17 @@ function societe_prepare_head(Societe $object) $head[$h][2] = 'card'; $h++; + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $nbContact = 0; // TODO + $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; + $head[$h][2] = 'contact'; + $h++; + } + if ($object->client==1 || $object->client==2 || $object->client==3) { $head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id; @@ -748,7 +759,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print ''; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print "\n".''."\n"; $param="socid=".$object->id; diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 89bbe24ea47..5d9f9280cc8 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -48,6 +48,16 @@ function commande_prepare_head(Commande $object) $h++; } + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; + $head[$h][2] = 'contact'; + $h++; + } + if (($conf->expedition_bon->enabled && $user->rights->expedition->lire) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)) { @@ -60,16 +70,6 @@ function commande_prepare_head(Commande $object) $h++; } - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); - $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; - $head[$h][2] = 'contact'; - $h++; - } - // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index e24fbb44f7a..aa9353201cf 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -34,16 +34,19 @@ if ($action == 'presend') $object->fetch_projet(); - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - // - if ($object->element == 'invoice_supplier') + if (! in_array($object->element, array('societe', 'user'))) { - $fileparams = dol_most_recent_file($diroutput . '/' . get_exdir($object->id,2,0,0,$object,$object->element).$ref, preg_quote($ref,'/').'([^\-])+'); - } + $ref = dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + $fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + // + if ($object->element == 'invoice_supplier') + { + $fileparams = dol_most_recent_file($diroutput . '/' . get_exdir($object->id,2,0,0,$object,$object->element).$ref, preg_quote($ref,'/').'([^\-])+'); + } - $file = $fileparams['fullname']; + $file = $fileparams['fullname']; + } // Define output language $outputlangs = $langs; @@ -72,16 +75,19 @@ if ($action == 'presend') } // Build document if it not exists - if (! $file || ! is_readable($file)) { - if ($object->element != 'member') - { - $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) { - dol_print_error($db, $object->error, $object->errors); - exit(); + if (! in_array($object->element, array('societe', 'user'))) + { + if (! $file || ! is_readable($file)) { + if ($object->element != 'member') + { + $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) { + dol_print_error($db, $object->error, $object->errors); + exit(); + } + $fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; } - $fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; } } @@ -106,7 +112,7 @@ if ($action == 'presend') if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set { include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); + $formmail->frommail=dolAddEmailTrackId($formmail->frommail, $trackid); } $formmail->withfrom = 1; diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index f1cca6a1696..a78981f32a1 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -87,8 +87,8 @@ PredefinedMailContentSendSupplierOrder=__CONTACTCIVNAME__\n\nYou will find here PredefinedMailContentSendSupplierInvoice=__CONTACTCIVNAME__\n\nYou will find here the invoice __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendShipping=__CONTACTCIVNAME__\n\nYou will find here the shipping __SHIPPINGREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendFichInter=__CONTACTCIVNAME__\n\nYou will find here the intervention __FICHINTERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ -PredefinedMailContentThirdparty=__CONTACTCIVNAME__\n\n__PERSONALIZED__\n\n__SIGNATURE__ -PredefinedMailContentUser=aa__PERSONALIZED__\n\n__SIGNATURE__ +PredefinedMailContentThirdparty=\n\n__SIGNATURE__ +PredefinedMailContentUser=\n\n__SIGNATURE__ DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available. ChooseYourDemoProfil=Choose the demo profile that best suits your needs... ChooseYourDemoProfilMore=...or build your own profile
(manual module selection) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 236faaaa232..89074892fa9 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -59,7 +59,7 @@ $action = (GETPOST('action','aZ09') ? GETPOST('action','aZ09') : 'view'); $cancel = GETPOST('cancel','alpha'); $backtopage = GETPOST('backtopage','alpha'); $confirm = GETPOST('confirm'); -$socid = GETPOST('socid','int'); +$socid = GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; if (empty($socid) && $action == 'view') $action='create'; @@ -2372,69 +2372,68 @@ else /* * Actions */ - print '
'."\n"; + if ($action != 'presend') + { + print '
'."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) - { - $at_least_one_email_contact = false; - $TContact = $object->contact_array_objects(); - foreach ($TContact as &$contact) + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { - if (!empty($contact->email)) + $at_least_one_email_contact = false; + $TContact = $object->contact_array_objects(); + foreach ($TContact as &$contact) { - $at_least_one_email_contact = true; - break; + if (!empty($contact->email)) + { + $at_least_one_email_contact = true; + break; + } } + + if (! empty($object->email) || $at_least_one_email_contact) + { + $langs->load("mails"); + print ''; + } + else + { + $langs->load("mails"); + print ''; + } + + if ($user->rights->societe->creer) + { + print ''."\n"; + } + + if ($user->rights->societe->supprimer) + { + print ''; + } + + if ($user->rights->societe->supprimer) + { + if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile + { + print '
'.$langs->trans('Delete').'
'."\n"; + } + else + { + print ''."\n"; + } + } } - if (! empty($object->email) || $at_least_one_email_contact) - { - $langs->load("mails"); - print ''; - } - else - { - $langs->load("mails"); - print ''; - } - - if ($user->rights->societe->creer) - { - print ''."\n"; - } - - if ($user->rights->societe->supprimer) - { - print ''; - } - - if ($user->rights->societe->supprimer) - { - if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile - { - print '
'.$langs->trans('Delete').'
'."\n"; - } - else - { - print ''."\n"; - } - } - } - - print '
'."\n"; + print '
'."\n"; + } //Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend'; } - if ($action == 'presend') + /*if ($action == 'presend') { - /* - * Affiche formulaire mail - */ - // By default if $action=='presend' $titreform='SendMail'; $topicmail=''; @@ -2491,31 +2490,6 @@ else $formmail->substit['__PERSONALIZED__']=''; // deprecated $formmail->substit['__CONTACTCIVNAME__']=''; - //Find the good contact adress - /* - $custcontact=''; - $contactarr=array(); - $contactarr=$object->liste_contact(-1,'external'); - - if (is_array($contactarr) && count($contactarr)>0) - { - foreach($contactarr as $contact) - { - if ($contact['libelle']==$langs->trans('TypeContact_facture_external_BILLING')) { - - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - - $contactstatic=new Contact($db); - $contactstatic->fetch($contact['id']); - $custcontact=$contactstatic->getFullName($langs,1); - } - } - - if (!empty($custcontact)) { - $formmail->substit['__CONTACTCIVNAME__']=$custcontact; - } - }*/ - // Tableau des parametres complementaires du post $formmail->param['action']=$action; @@ -2533,14 +2507,15 @@ else print $formmail->get_form(); dol_fiche_end(); - } - else + }*/ + + if ($action != 'presend') { + print '
'; if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) { - print '
'; - print ''; // ancre + print ''; // ancre /* * Documents generes @@ -2553,35 +2528,34 @@ else $var=true; print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); - - print '
'; - - - print '
'; - - print '
'; } - print '

'; - // Subsidiaries list if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES)) { - $result=show_subsidiaries($conf,$langs,$db,$object); + $result=show_subsidiaries($conf,$langs,$db,$object); } - // Contacts list - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } + print '
'; - // Addresses list - if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) - { - $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } + $MAX = 5; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAX); // Show all action for thirdparty + + print '
'; } + + // Presend form + $modelmail='thirdparty'; + $defaulttopic='Information'; + $diroutput = $conf->societe->dir_output; + $trackid = 'thi'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + } } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 56ca7d3042b..1c8c515545a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1898,6 +1898,11 @@ class Societe extends CommonObject $label.= '' . $langs->trans("ShowMargin") . ''; $linkstart = ''; + $linkstart = 'load("commercial"); +$langs->load("bills"); +$langs->load("banks"); +$langs->load("users"); +if (! empty($conf->categorie->enabled)) $langs->load("categories"); +if (! empty($conf->incoterm->enabled)) $langs->load("incoterm"); +if (! empty($conf->notification->enabled)) $langs->load("mails"); + +$mesg=''; $error=0; $errors=array(); + +$action = (GETPOST('action','aZ09') ? GETPOST('action','aZ09') : 'view'); +$cancel = GETPOST('cancel','alpha'); +$backtopage = GETPOST('backtopage','alpha'); +$confirm = GETPOST('confirm'); +$socid = GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int'); +if ($user->societe_id) $socid=$user->societe_id; +if (empty($socid) && $action == 'view') $action='create'; + +$object = new Societe($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('thirdpartycard','globalcard')); + +if ($action == 'view' && $object->fetch($socid)<=0) +{ + $langs->load("errors"); + print($langs->trans('ErrorRecordNotFound')); + exit; +} + +// Get object canvas (By default, this is not defined, so standard usage of dolibarr) +$object->getCanvas($socid); +$canvas = $object->canvas?$object->canvas:GETPOST("canvas"); +$objcanvas=null; +if (! empty($canvas)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('thirdparty', 'card', $canvas); +} + +// Security check +$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas); + + + + +/* + * Actions + */ + +$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + if ($cancel) + { + $action=''; + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + } +} + + +/* + * View + */ + +$form = new Form($db); +$formfile = new FormFile($db); +$formadmin = new FormAdmin($db); +$formcompany = new FormCompany($db); + +if ($socid > 0 && empty($object->id)) +{ + $result=$object->fetch($socid); + if ($result <= 0) dol_print_error('',$object->error); +} + +$title=$langs->trans("ThirdParty"); +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('Card'); +$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('',$title,$help_url); + +$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + +if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) +{ + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates + $objcanvas->display_canvas($action); // Show template +} +else +{ + + if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); + //if ($res < 0) { dol_print_error($db); exit; } + + + $head = societe_prepare_head($object); + + dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); + + // Confirm delete third party + if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); + } + + if ($action == 'merge') + { + $formquestion = array( + array( + 'name' => 'soc_origin', + 'label' => $langs->trans('MergeOriginThirdparty'), + 'type' => 'other', + 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200') + ) + ); + + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 200); + } + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); + + + print '
'; + + dol_fiche_end(); + + + if ($action != 'presend') + { + print '
'; + + // Contacts list + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + } + + // Addresses list + if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) + { + $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + } + + + print '
'; + + } + +} + + +// End of page +llxFooter(); +$db->close(); From 6bdfa99fc2f2c0dbec14b06035bf4a8f32be741e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 20:07:01 +0200 Subject: [PATCH 6/7] FIX The backtopage --- htdocs/contact/card.php | 9 +++++++++ htdocs/core/lib/company.lib.php | 11 +++++++++++ htdocs/ecm/docfile.php | 6 +++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 43b9b7e4760..ac3c52ae8f5 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -396,6 +396,15 @@ if (empty($reshook)) $action = 'edit'; } } + + if (! $error && empty($errors)) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + } } } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 54c5abfda93..f22da301ec4 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -52,6 +52,17 @@ function societe_prepare_head(Societe $object) { //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); $nbContact = 0; // TODO + + $sql = "SELECT COUNT(p.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; + $sql .= " WHERE p.fk_soc = ".$object->id; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $nbContact = $obj->nb; + } + $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; diff --git a/htdocs/ecm/docfile.php b/htdocs/ecm/docfile.php index a856ab22c36..f6719d08604 100644 --- a/htdocs/ecm/docfile.php +++ b/htdocs/ecm/docfile.php @@ -117,9 +117,9 @@ if (! ($result >= 0)) if ($cancel) { $action =''; - if ($backtourl) + if ($backtopage) { - header("Location: ".$backtourl); + header("Location: ".$backtopage); exit; } else @@ -387,7 +387,7 @@ if ($action != 'edit') { print ''.$langs->trans('Edit').''; - //print ''.$langs->trans('Cancel').''; + //print ''.$langs->trans('Cancel').''; } /* if ($user->rights->ecm->setup) From e878f3cfd5ba574c56d8a93486347b7b3eaf894b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Sep 2017 20:15:56 +0200 Subject: [PATCH 7/7] No more need of contacts on each tab by default --- htdocs/core/class/conf.class.php | 5 ++--- htdocs/societe/contact.php | 38 +++++++------------------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index aa1651d6fc6..e0e032d7e25 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -259,9 +259,8 @@ class Conf // Load translation object with current language if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT="en_US"; - // By default, we repeat info on all tabs - if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1; - if (! isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) $this->global->MAIN_REPEATADDRESSONEACHTAB=1; + //if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1; + //if (! isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) $this->global->MAIN_REPEATADDRESSONEACHTAB=1; $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index f69eef22795..56c729e76f4 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -151,43 +151,21 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) else { - if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); - //if ($res < 0) { dol_print_error($db); exit; } + if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); + //if ($res < 0) { dol_print_error($db); exit; } - $head = societe_prepare_head($object); + $head = societe_prepare_head($object); - dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); - // Confirm delete third party - if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) - { - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); - } + $linkback = ''.$langs->trans("BackToList").''; - if ($action == 'merge') - { - $formquestion = array( - array( - 'name' => 'soc_origin', - 'label' => $langs->trans('MergeOriginThirdparty'), - 'type' => 'other', - 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200') - ) - ); + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 200); - } - - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); - - - print '
'; - - dol_fiche_end(); + dol_fiche_end(); + print '
'; if ($action != 'presend') {