diff --git a/build/debian/install.forced.php.install b/build/debian/install.forced.php.install index 56eef3287a6..e55ffae138e 100644 --- a/build/debian/install.forced.php.install +++ b/build/debian/install.forced.php.install @@ -7,7 +7,7 @@ // $force_install_packager='deb'; -$force_install_noedit=2; +$force_install_noedit=1; $force_install_message='KeepDefaultValuesDeb'; #$force_install_main_data_root='/usr/share/dolibarr/documents'; $force_install_main_data_root='/var/lib/dolibarr/documents'; diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index d287afe4b86..b1282719cda 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -509,7 +509,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/documents`; # Removed known external modules to avoid any error when packaging from env where external modules are tested - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/custom/*`; # For custom we want to keep dir + #$ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \;`; # For custom we want to keep dir $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/allscreens*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/ancotec*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/cabinetmed*`; @@ -550,6 +550,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/doc`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/example`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/test`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mobiledetect/mobiledetectlib/.gitmodules`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/php-iban/docs`; diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index d2b039a28e0..0b4aa70e548 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -901,8 +901,8 @@ if ($id) if ($id == 4) print ''; print ''; print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; + $searchpicto=$form->showFilterAndCheckAddButtons(0); + print $searchpicto; print ''; print ''; diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index f7bbbb97969..eaf69f34f1f 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -130,7 +130,7 @@ print '
'; print ''; print ''; -dol_fiche_head($head, 'export', $langs->trans("Configuration"), 0, 'cron'); +dol_fiche_head($head, 'export', $langs->trans("Configuration"), -1, 'cron'); $var = true; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 3ea77a24b43..899aaa1a3d2 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -171,7 +171,7 @@ print ''; print ''; print ''; -dol_fiche_head($head, 'general', $langs->trans("Configuration"), 0, 'cron'); +dol_fiche_head($head, 'general', $langs->trans("Configuration"), -1, 'cron'); // Default mode for calculating turnover (parameter ACCOUNTING_MODE) @@ -299,7 +299,7 @@ print '
transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")); +print '
'.$langs->trans("AccountancySetupDoneFromAccountancyMenu", $langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")).'
'; print '
'; print ''; diff --git a/htdocs/accountancy/admin/journals.php b/htdocs/accountancy/admin/journals.php index 03b51089d9a..677f2a743e5 100644 --- a/htdocs/accountancy/admin/journals.php +++ b/htdocs/accountancy/admin/journals.php @@ -94,7 +94,7 @@ print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'titl $head = admin_accounting_prepare_head(null); -dol_fiche_head($head, 'journal', $langs->trans("Configuration"), 0, 'cron'); +dol_fiche_head($head, 'journal', $langs->trans("Configuration"), -1, 'cron'); $sql = "SELECT j.rowid, j.code, j.label, j.nature, j.active"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_journal as j"; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 845e0a62540..c5830b0b003 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -285,7 +285,7 @@ if ($result) { print ''; print ''; print ''; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $searchpicto=$form->showFilterButtons(); print $searchpicto; print ''; print ''; @@ -303,7 +303,7 @@ if ($result) { print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"'); $checkpicto=''; if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); - print_liste_field_titre($checkpitco, '', '', '', '', 'align="center"'); + print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"'); print "\n"; $facture_static = new Facture($db); diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 54772ebf1a4..ff9ca6fa1a3 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -129,15 +129,18 @@ if (! empty($conf->don->enabled)) print "
\n"; print "
\n"; }*/ + $step++; -$textlink=''.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuBankCash").''; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink); +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").''); print "
\n"; print "
\n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").'')."
\n"; +$textlink=''.$langs->transnoentitiesnoconv("MenuBankCash").''; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink); print "
\n"; +print "
\n"; + print "
\n"; print_fiche_titre($langs->trans("AccountancyAreaDescActionFreq"), '', 'object_calendarweek'); diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index c8f68d2151c..5cb10e31e6d 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -145,7 +145,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent- $result=$object->delete($user); if ($result > 0) { - header("Location: card_subscriptions.php?rowid=".$object->fk_adherent); + header("Location: ".DOL_URL_ROOT."/adherents/card.php?rowid=".$object->fk_adherent); exit; } else diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 3b205f49cd2..fd1da0c328b 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -257,8 +257,14 @@ $var=true; $var=! $var; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + print ''; -print $langs->trans("FreeLegalTextOnChequeReceipts").' ('.$langs->trans("AddCRIfTooLong").')
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='BANK_CHEQUERECEIPT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 3933f5d00ab..a4680f4d16e 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -565,12 +565,18 @@ print " \n"; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print '
'; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnOrders").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -593,11 +599,6 @@ print ""; print ''; print ""; print ''; -$substitutionarray=pdf_getSubstitutionArray($langs); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; print $form->textwithpicto($langs->trans("WatermarkOnDraftOrders"), $htmltext); print ''; print ''; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index bc3ea402704..ddd8c6f1c00 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -502,9 +502,15 @@ print ''.$langs->trans("Value").''; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print ''; -print $langs->trans("FreeLegalTextOnContracts").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='CONTRACT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -521,7 +527,8 @@ print ''."\n"; //Use draft Watermark print ''; -print $langs->trans("WatermarkOnDraftContractCards").''; +print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext); +print ''; print ''; print ''."\n"; diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 0bc620c41bf..8a9bd4f209b 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -56,6 +56,10 @@ $defaultvalue = GETPOST('defaultvalue'); $defaulturl=preg_replace('/^\//', '', $defaulturl); +$urlpage = GETPOST('urlpage'); +$key = GETPOST('key'); +$value = GETPOST('value'); + /* * Actions @@ -81,25 +85,51 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP } -if ($action == 'add' || (GETPOST('add') && $action != 'update')) +if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) { $error=0; - if (empty($defaulturl)) + if (($action == 'add' || (GETPOST('add') && $action != 'update'))) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); - $error++; + if (empty($defaulturl)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); + $error++; + } + if (empty($defaultkey)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); + $error++; + } } - if (empty($defaultkey)) + if (GETPOST('actionmodify')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Key")), null, 'errors'); - $error++; + if (empty($urlpage)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); + $error++; + } + if (empty($key)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); + $error++; + } } + if (! $error) { $db->begin(); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; + + if ($action == 'add' || (GETPOST('add') && $action != 'update')) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; + } + if (GETPOST('actionmodify')) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'"; + $sql.= " WHERE rowid = ".$id; + } + $result = $db->query($sql); if ($result > 0) { @@ -176,6 +206,10 @@ $head=defaultvalues_prepare_head(); dol_fiche_head($head, $mode, '', -1, ''); +if ($mode == 'sortorder') +{ + print info_admin($langs->trans("WarningSettingSortOrder")).'
'; +} print ''; print ''; @@ -187,29 +221,37 @@ $texthelp=$langs->trans("PageUrlForDefaultValues"); if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php'); else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php'); $texturl=$form->textwithpicto($langs->trans("Url"), $texthelp); -print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'defaulturl','',$param,'',$sortfield,$sortorder); +print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'page,param','',$param,'',$sortfield,$sortorder); $texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField"); -if ($mode != 'sortorder') $textkey=$form->textwithpicto($langs->trans("Key"), $texthelp); -else $textkey=$form->textwithpicto($langs->trans("Key"), $texthelp); -print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'defaultkey','',$param,'',$sortfield,$sortorder); +if ($mode != 'sortorder') +{ + $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); +} +else +{ + $texthelp='field or alias.field'; + $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); +} +print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'param','',$param,'',$sortfield,$sortorder); if ($mode != 'sortorder') { $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; // See list into GETPOST $texthelp.='__USERID__
'; + $texthelp.='__SUPERVISORID__
'; $texthelp.='__MYCOUNTRYID__
'; $texthelp.='__DAY__
'; $texthelp.='__MONTH__
'; $texthelp.='__YEAR__
'; if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__
'; - $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp); + $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); } else { $texthelp='ASC or DESC'; $textvalue=$form->textwithpicto($langs->trans("SortOrder"), $texthelp); } -print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'defaultvalue', '', $param, '', $sortfield, $sortorder); +print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder); if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,page','',$param,'',$sortfield,$sortorder); print ''; print "\n"; @@ -269,9 +311,17 @@ if ($result) print ''; - print ''.$obj->page.''."\n"; - print ''.$obj->param.''."\n"; - + print ''; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->page; + else print ''; + print ''."\n"; + + // Key + print ''; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param; + else print ''; + print ''."\n"; + // Value print ''; /*print ''; @@ -279,11 +329,25 @@ if ($result) print ''; print ''; */ - print $obj->value; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->value; + else print ''; print ''; print ''; - print ''.img_delete().''; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) + { + print ''.img_edit().''; + print '   '; + print ''.img_delete().''; + } + else + { + print ''; + print ''; + print '
'; + print ''; + print ''; + } print ''; print "\n"; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 95692672523..125f913eb8d 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -660,7 +660,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null - + if ($id == 10 && isset($_POST["code"])) // Spaces are not allowed into code + { + $_POST["code"]=preg_replace('/\s/','',$_POST["code"]); + } + // Si verif ok et action add, on ajoute la ligne if ($ok && GETPOST('actionadd')) { @@ -1302,10 +1306,10 @@ if ($id) if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit'); print ''; + print '
'; print ''; print ''; print ''; - print '
'; print ''; print ''; } diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index ef8b10c411f..d31b788a1ab 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -502,8 +502,14 @@ print ""; print "".$langs->trans("Parameter")."\n"; print ""; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + print ''; -print $langs->trans("FreeLegalTextOnShippings").' ('.$langs->trans("AddCRIfTooLong").')
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='SHIPPING_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -518,7 +524,7 @@ else print "\n"; print ''; -print $langs->trans("WatermarkOnDraft").'
'; +print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext).'
'; print ''; print "\n"; diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index eda3c6bd6ae..dad17585e2e 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -505,9 +505,15 @@ print ''; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print ''; -print $langs->trans("FreeLegalTextOnExpenseReports").' ('.$langs->trans("AddCRIfTooLong").')
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnExpenseReports"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='EXPENSEREPORT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -524,7 +530,7 @@ print ''."\n"; //Use draft Watermark print ''; -print $langs->trans("WatermarkOnDraftOrders").'
'; +print $form->textwithpicto($langs->trans("WatermarkOnDraftExpenseReports"), $htmltext).'
'; print ''; print ''."\n"; diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 7f81a5d0fef..30646b749fa 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -206,13 +206,13 @@ print ''.$langs->trans("Example").''; print ''; print ''; print ''.$langs->trans("Title").''; -print ''; +print ''; print ''.$langs->trans('RSSUrlExample').''; print ''; print ''; print ''.$langs->trans('RSSUrl').''; -print ''; +print ''; print 'http://news.google.com/news?ned=us&topic=h&output=rss
http://www.dolibarr.org/rss'; print ''; print ''; @@ -243,10 +243,12 @@ if ($resql) preg_match('/^([0-9]+)/i',$obj->note,$reg); $idrss = $reg[1]; - //print "x".$idrss; + $keyrssurl="EXTERNAL_RSS_URLRSS_".$idrss; + $keyrsstitle="EXTERNAL_RSS_URLRSS_".$idrss; + //print "x".$idrss; $rssparser=new RssParser($db); - $result = $rssparser->parser(@constant("EXTERNAL_RSS_URLRSS_".$idrss), 5, 300, $conf->externalrss->dir_temp); + $result = $rssparser->parser($conf->global->$keyrssurl, 5, 300, $conf->externalrss->dir_temp); $var=true; @@ -269,13 +271,13 @@ if ($resql) print ''; print "".$langs->trans("Title").""; - print ""; + print "global->$keyrsstitle . "\">"; print ""; print ''; print "".$langs->trans("URL").""; - print ""; + print "global->$keyrssurl . "\">"; print ""; @@ -304,6 +306,8 @@ if ($resql) print "".$langs->trans("Logo").""; print ''; $imageurl=$rssparser->getImageUrl(); + $linkrss=$rssparser->getLink(); + if (! preg_match('/^http/', $imageurl)) $imageurl=$linkrss.$imageurl; if ($imageurl) print ''; else print $langs->trans("None"); print ''; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index e7f74f85e5e..d89c9711e3f 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -733,12 +733,18 @@ print '\n"; print '
'; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print '
'; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnInvoices").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -760,11 +766,6 @@ print ''; print ''; print ''; print ''; -$substitutionarray=pdf_getSubstitutionArray($langs); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext); print ''; print ''; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 6c73afcf8f5..0b01f56857e 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -534,12 +534,18 @@ print " \n"; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print ''; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnInterventions").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnInterventions"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='FICHINTER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -562,7 +568,8 @@ print ""; print ''; print ""; print ''; -print $langs->trans("WatermarkOnDraftInterventionCards").''; +print $form->textwithpicto($langs->trans("WatermarkOnDraftInterventionCards"), $htmltext).'
'; +print ''; print ''; print ''; print ''; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 281f1934296..143c54ec24d 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -479,12 +479,18 @@ print ' '; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print ''; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnDeliveryReceipts").' ('.$langs->trans("AddCRIfTooLong").')
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='DELIVERY_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index a5166ec69f2..88f2d8cd1c1 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -117,7 +117,7 @@ $linkback=''.$langs->trans("BackToM print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'payment', $langs->trans("Invoices"), 0, 'invoice'); +dol_fiche_head($head, 'payment', $langs->trans("Invoices"), -1, 'invoice'); /* * Numbering module diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 76179fac66c..6a9884e263c 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -570,11 +570,17 @@ print "\n"; print ''; */ +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + print '
'; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnProposal").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnProposal"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -596,12 +602,7 @@ print ""; print ''; print ""; print ''; -$substitutionarray=pdf_getSubstitutionArray($langs); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; -print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext); +print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext).'
'; print ''; print ''; print ''; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 2619951e1b5..19f0e6fc8e2 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -471,8 +471,14 @@ print ''.$langs->trans("Value").''; print ' '; print "\n"; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + print ''; -print $langs->trans("FreeLegalTextOnInvoices").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='SUPPLIER_INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index d54f0e367aa..a30e7de2654 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -491,6 +491,7 @@ print ''.$langs->trans("Value").''; print ' '; print "\n"; $var=false; + //if ($conf->global->MAIN_FEATURES_LEVEL > 0) //{ print ''; @@ -536,8 +537,14 @@ else } */ +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + print ''; -print $langs->trans("FreeLegalTextOnOrders").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='SUPPLIER_ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 703fbc482e9..345f622a533 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -523,12 +523,18 @@ print ''.$langs->trans("Value")."\n"; print " \n"; print ""; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print ''; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnSupplierProposal").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnSupplierProposal"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='SUPPLIER_PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -550,7 +556,8 @@ print ""; print ''; print ""; print ''; -print $langs->trans("WatermarkOnDraftSupplierProposal").''; +print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext).'
'; +print ''; print ''; print ''; print ''; diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 6d3ee6ced8e..75f151d45b9 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -71,7 +71,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $transkey=''; $transvalue=''; @@ -114,8 +114,16 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update')) } else { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); + + $db->rollback(); + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings'); + } + else + { + setEventMessages($db->lasterror(), null, 'errors'); + } $action=''; } } @@ -407,9 +415,17 @@ if ($mode == 'searchkey') print ''.$langcode.''.$key.''; print dol_escape_htmltag($val); print ''; - if ($val != $newlangfileonly->tab_translate[$key]) + if (! empty($newlangfileonly->tab_translate[$key])) { - $htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]); + if ($val != $newlangfileonly->tab_translate[$key]) + { + $htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]); + print $form->textwithpicto('', $htmltext, 1, 'info'); + } + } + else + { + $htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key); print $form->textwithpicto('', $htmltext, 1, 'warning'); } /*if (! empty($conf->multicompany->enabled) && !$user->entity) diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index b0c81ec18af..06e9a7b93a4 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -375,11 +375,11 @@ if ($id) // dans les dictionnaires de donnees $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate - $align="left"; + $align=''; if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($valuetoshow != '') { - print ''; + print ''; if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print '
'.$valuetoshow.' '.img_help(1,$valuetoshow).''; else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); else print $valuetoshow; @@ -413,14 +413,11 @@ if ($id) $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; - if ($id == 3) unset($fieldlist[2]); - if (empty($reshook)) { fieldListWebsites($fieldlist,$obj,$tabname[$id],'add'); } - if ($id == 4) print ''; print ''; if ($action != 'edit') { @@ -430,15 +427,9 @@ if ($id) print ""; $colspan=count($fieldlist)+2; - if ($id == 4) $colspan++; - - if (! empty($alabelisused) && $id != 25) // If there is one label among fields, we show legend of * - { - print '* '.$langs->trans("LabelUsedByDefault").'.'; - } - print ' '; // Keep   to have a line with enough height } + print ''; print '
'; @@ -453,6 +444,15 @@ if ($id) $var=true; if ($num) { + print '
'; + + print '
'; + print ''; + print ''; + print ''; + + print ''; + // There is several pages if ($num > $listlimit) { @@ -503,14 +503,9 @@ if ($id) $obj = $db->fetch_object($resql); //print_r($obj); - print ''; + print ''; if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) { - print ''; - print ''; - print ''; - print ''; - $tmpaction='edit'; $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks @@ -548,16 +543,6 @@ if ($id) $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&id='.$id.'&'; - // Favorite - // Only activated on country dictionary - if ($id == 4) - { - print ''; - } - // Active print '
'; - if ($iserasable) print ''.$actl[$obj->favorite].''; - else print $langs->trans("AlwaysActive"); - print ''; print ''.$actl[$obj->status].''; @@ -575,15 +560,15 @@ if ($id) } $i++; } + + print '
'; + + print '
'; } } else { dol_print_error($db); } - - print ''; - - print ''; } print '
'; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 31def3d1b29..aae1398109d 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1090,11 +1090,15 @@ if ($id > 0) if (! empty($conf->commande->enabled)) { - if (! empty($orders2invoice) && $orders2invoice > 0) print ''; - else print ''; + if ($object->client != 0 && $object->client != 2) + { + if (! empty($orders2invoice) && $orders2invoice > 0) print ''; + else print ''; + } + else print ''; } - - if ($object->client != 0) print ''; + + if ($object->client != 0 && $object->client != 2) print ''; else print ''; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index bf1f993bcdc..82050b7b586 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -464,6 +464,7 @@ class Commande extends CommonOrder if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; // We increment stock of product (and sub-products) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr",$this->ref)); if ($result < 0) { $error++; $this->error=$mouvP->error; break; } diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 0bb518662d6..df6e6b1c8c8 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -117,7 +117,7 @@ if ($action == 'add') if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { - setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error'); + setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors'); $action='create'; // Force chargement page en mode creation $error++; } diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index ae545c695c3..c7a43c737de 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -70,7 +70,7 @@ print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Invoices"), 0, 'invoice'); +dol_fiche_head($head, 'attributes', $langs->trans("Invoices"), -1, 'invoice'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index d7fd3367b67..3a5f8c3387f 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -71,7 +71,7 @@ print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), 0, 'invoice'); +dol_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), -1, 'invoice'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 21e0c854f6b..b516ccd2f23 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2191,7 +2191,7 @@ if ($action == 'create') else { print ''; - print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty'); + print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // Option to reload page to retrieve customer informations. Note, this clear other input if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index a2ce21a8971..f86f786e0fb 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -727,6 +727,10 @@ class ExtraFields { $showsize='minwidth400imp'; } + elseif ($type == 'boolean') + { + $showsize=''; + } else { if (round($size) < 12) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b839e46dc8b..3275ee0f303 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -994,7 +994,7 @@ class Form print img_picto($langs->trans("Search"), 'search'); } } - print 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; + print 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; if ($hidelabel == 3) { print img_picto($langs->trans("Search"), 'search'); } diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index c63227e1601..9fc1739334c 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -220,9 +220,9 @@ abstract class DoliDB implements Database /** * Define sort criteria of request * - * @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda, t2.fieldb' + * @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda, t2.fieldb' * @param 'ASC'|'DESC' $sortorder Sort order - * @return string String to provide syntax of a sort sql string + * @return string String to provide syntax of a sort sql string */ function order($sortfield=null,$sortorder=null) { @@ -230,18 +230,25 @@ abstract class DoliDB implements Database { $return=''; $fields=explode(',',$sortfield); + $orders=explode(',',$sortorder); + $i=0; foreach($fields as $val) { if (! $return) $return.=' ORDER BY '; - else $return.=','; + else $return.=', '; $return.=preg_replace('/[^0-9a-z_\.]/i','',$val); + + $tmpsortorder = trim($orders[$i]); + // Only ASC and DESC values are valid SQL - if (strtoupper($sortorder) === 'ASC') { + if (strtoupper($tmpsortorder) === 'ASC') { $return .= ' ASC'; - } elseif (strtoupper($sortorder) === 'DESC') { + } elseif (strtoupper($tmpsortorder) === 'DESC') { $return .= ' DESC'; } + + $i++; } return $return; } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 6d90a1afed3..77da09b3d64 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1584,7 +1584,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu $sqlprotectagainstexternals=''; $ret=array(); - // find the subdirectory name as the reference + // Find the subdirectory name as the reference. For exemple original_file='10/myfile.pdf' -> refname='10' if (empty($refname)) $refname=basename(dirname($original_file)."/"); $relative_original_file = $original_file; @@ -1752,6 +1752,18 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu $original_file=$conf->fckeditor->dir_output.'/'.$original_file; } + // Wrapping for users + else if ($modulepart == 'user' && !empty($conf->user->dir_output)) + { + $canreaduser=(! empty($fuser->admin) || $fuser->rights->user->user->lire); + if ($fuser->id == (int) $refname) { $canreaduser=1; } // A user can always read its own card + if ($canreaduser || preg_match('/^specimen/i',$original_file)) + { + $accessallowed=1; + } + $original_file=$conf->user->dir_output.'/'.$original_file; + } + // Wrapping for third parties else if (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d430a8ea53b..0d54593f0db 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -246,24 +246,64 @@ function dol_shutdown() * @param mixed $options Options to pass to filter_var when $check is set to custom * @return string|string[] Value found (string or array), or '' if check fails */ -function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) +function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL) { if (empty($method)) { $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); - + // Management of default values - if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + if (! isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values { - $relativepathstring = preg_replace('/\.[a-z]+$/', '', $_SERVER["PHP_SELF"]); - if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); - $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); - $relativepathstring = preg_replace('/^\//', '', $relativepathstring); - $relativepathstring=dol_string_nospecial($relativepathstring, '-'); - // $relativepathstring is now string that identify the page: '_societe_card', '_agenda_card', ... - $keyfordefaultvalue = 'MAIN_DEFAULT_FOR_'.$relativepathstring.'_'.$paramname; - global $conf; - if (isset($conf->global->$keyfordefaultvalue)) $out = $conf->global->$keyfordefaultvalue; + if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + { + $relativepathstring = $_SERVER["PHP_SELF"]; + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + global $user; + if (! empty($user->default_values)) // $user->default_values defined from menu default values, and values loaded not at first + { + //var_dump($user->default_values[$relativepathstring]['createform']); + if (isset($user->default_values[$relativepathstring]['createform'][$paramname])) $out = $user->default_values[$relativepathstring]['createform'][$paramname]; + } + } + // Management of default search_filters and sort order + elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + { + $relativepathstring = $_SERVER["PHP_SELF"]; + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + global $user; + if (! empty($user->default_values)) // $user->default_values defined from menu default values, and values loaded not at first + { + //var_dump($user->default_values[$relativepathstring]); + if ($paramname == 'sortfield') + { + if (isset($user->default_values[$relativepathstring]['sortorder'])) + { + foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val) + { + if ($out) $out.=', '; + $out.=$key; + } + } + } + elseif ($paramname == 'sortorder') + { + if (isset($user->default_values[$relativepathstring]['sortorder'])) + { + foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val) + { + if ($out) $out.=', '; + $out.=$val; + } + } + } + elseif (isset($user->default_values[$relativepathstring]['filters'][$paramname])) $out = $user->default_values[$relativepathstring]['filters'][$paramname]; + } + } } } elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:''; @@ -303,6 +343,11 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) global $user; $out = $user->id; } + elseif ($reg[1] == 'SUPERVISORID') + { + global $user; + $out = $user->fk_user; + } elseif ($reg[1] == 'ENTITYID') { global $conf; @@ -3155,6 +3200,9 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m $tag='th'; if ($thead==2) $tag='div'; + $tmpsortfield=explode(',',$sortfield); + $sortfield=trim($tmpsortfield[0]); + // If field is used as sort criteria we use a specific class // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom") if ($field && ($sortfield == $field || $sortfield == preg_replace("/^[^\.]+\./","",$field))) $out.= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '. $moreattrib.'>'; @@ -3169,13 +3217,13 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m if ($field != $sortfield) { - if ($sortorder == 'DESC') $out.= ''; - if ($sortorder == 'ASC' || ! $sortorder) $out.= ''; + if (preg_match('/^DESC/', $sortorder)) $out.= ''; + else $out.= ''; } else { - if ($sortorder == 'DESC' || ! $sortorder) $out.= ''; - if ($sortorder == 'ASC') $out.= ''; + if (preg_match('/^ASC/', $sortorder)) $out.= ''; + else $out.= ''; } } @@ -3204,12 +3252,12 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m } else { - if ($sortorder == 'DESC' ) { + if (preg_match('/^DESC/', $sortorder)) { //$out.= ''.img_down("A-Z",0).''; //$out.= ''.img_up("Z-A",1).''; $sortimg.= ''.img_up("Z-A",0).''; } - if ($sortorder == 'ASC' ) { + if (preg_match('/^ASC/', $sortorder)) { //$out.= ''.img_down("A-Z",1).''; //$out.= ''.img_up("Z-A",0).''; $sortimg.= ''.img_down("A-Z",0).''; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index dc0541e39ef..66d66ec7c8f 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -5,6 +5,7 @@ * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2015-2016 Raphaël Doursenaud + * Copyright (C) 2017 Juanjo Menent * * 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 @@ -1439,7 +1440,7 @@ function dol_print_reduction($reduction,$langs) } else { - $string = $reduction.'%'; + $string = price($reduction).'%'; } return $string; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f85885def1d..360a93cf61b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -800,9 +800,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->facture->enabled)) { $langs->load("bills"); - $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire); + $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire, '', $mainmenu, 'customers_bills'); $newmenu->add("/compta/facture/card.php?action=create",$langs->trans("NewBill"),1,$user->rights->facture->creer); - $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("List"),1,$user->rights->facture->lire); + $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("List"),1,$user->rights->facture->lire, '', $mainmenu, 'customers_bills'); if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills/', $leftmenu)) { diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index dab925eef1d..d1697b767bd 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -69,19 +69,18 @@ class pdf_rouget extends ModelePdfExpedition // Define position of columns $this->posxdesc=$this->marge_gauche+1; - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 76; + $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; $this->posxpuht=$this->page_largeur - $this->marge_droite; - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { + if (!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 130; - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 100; - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 70; + $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; + $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; + $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; - } $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images @@ -344,7 +343,7 @@ class pdf_rouget extends ModelePdfExpedition // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); - + $tab_height = $tab_height - $height_note; $tab_top = $nexY+6; } @@ -459,16 +458,17 @@ class pdf_rouget extends ModelePdfExpedition $weighttxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { - $weighttxt=$object->lines[$i]->weight*$object->lines[$i]->qty_shipped.' '.measuring_units_string($object->lines[$i]->weight_units,"weight"); + $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight"); } $voltxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { - $voltxt=$object->lines[$i]->volume*$object->lines[$i]->qty_shipped.' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume"); + $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume"); } - - $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?', ':'').$voltxt,'','C'); - + + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt, 0, 0, false, true, 'C'); + //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C'); + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->SetXY($this->posxqtyordered, $curY); @@ -479,27 +479,27 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C'); if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) -{ + { $pdf->SetXY($this->posxpuht, $curY); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); $pdf->SetXY($this->posxtotalht, $curY); $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R'); - } + $nexY+=3; + if ($weighttxt && $voltxt) $nexY+=2; + // Add line if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Passe espace entre les lignes - // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { @@ -650,7 +650,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); @@ -658,20 +658,20 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); - } + } // Total Weight if ($totalWeighttoshow) { - $pdf->SetXY($col2x-20, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2+20, $tab2_hl, $totalWeighttoshow, 0, 'R', 1); + $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); $index++; } if ($totalVolumetoshow) { - $pdf->SetXY($col2x-20, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2+20, $tab2_hl, $totalVolumetoshow, 0, 'R', 1); + $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); $index++; } @@ -949,6 +949,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFillColor(230,230,230); $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); $pdf->SetTextColor(0,0,60); + $pdf->SetFillColor(255,255,255); // Show sender name $pdf->SetXY($posx+2,$posy+3); diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 627fcfd6fd9..917760dc900 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/import/modules_import.php'; /** * Class to import Excel files */ -class Importxlsx extends ModeleImports +class ImportXlsx extends ModeleImports { var $db; var $datatoimport; diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index 91af81ef178..195cab19f7f 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -104,8 +104,10 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface private function getFilename($suffixinfilename='') { global $conf; - if (! empty($conf->global->SYSLOG_FILE)) $tmp=str_replace('DOL_DATA_ROOT', DOL_DATA_ROOT, $conf->global->SYSLOG_FILE); - else $tmp='dolibarr.log'; + + if (empty($conf->global->SYSLOG_FILE)) $tmp=DOL_DATA_ROOT.'/dolibarr.log'; + else $tmp=str_replace('DOL_DATA_ROOT', DOL_DATA_ROOT, $conf->global->SYSLOG_FILE); + return $suffixinfilename?preg_replace('/\.log$/i', $suffixinfilename.'.log', $tmp):$tmp; } diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index c33d79d062b..c14927ec048 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -34,7 +34,7 @@ print '
'; $extrafields->fetch_name_optionals_label($elementtype); print '
'; -print ""; +print '
'; print ''; print ''; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index a9ba1ef80aa..4c2716e311a 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -753,7 +753,6 @@ if ($object->id > 0) print ''; - print '
'; if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) { diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index 339fc1cb6fd..40037dce274 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -268,9 +268,8 @@ if ($result > 0) print ''; print ''; print ''; } diff --git a/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php b/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php old mode 100644 new mode 100755 diff --git a/htdocs/install/check.php b/htdocs/install/check.php index b37837df663..bc7082b8d9d 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -363,7 +363,7 @@ else // Show first install line $choice = ''; - $choice .= ''; $choice .= ''; - $choice .= '
'.$langs->trans("Position").''.$langs->trans('BankAccount').''; $accountstatic=new Account($db); - $accountstatic->id=$bankline->fk_account; - $accountstatic->label=$bankline->bank_account_ref.' - '.$bankline->bank_account_label; - print $accountstatic->getNomUrl(0); + $accountstatic->fetch($bankline->fk_account); + print $accountstatic->getNomUrl(1); print '
'.$langs->trans("FreshInstall").''; $choice .= ''; + $choice .= ''; $choice .= $langs->trans("FreshInstallDesc"); if (empty($dolibarr_main_db_host)) // This means install process was not run { @@ -459,7 +459,7 @@ else $choice .= '
'.$langs->trans("Upgrade").'
'.$newversionfrom.$newversionfrombis.' -> '.$newversionto.'
'; + $choice .= ''; $choice .= $langs->trans("UpgradeDesc"); if ($recommended_choice) diff --git a/htdocs/install/default.css b/htdocs/install/default.css index 257f2d99af8..9725b06b8bc 100644 --- a/htdocs/install/default.css +++ b/htdocs/install/default.css @@ -1,5 +1,5 @@ /* Copyright (C) 2004 Rodolphe Quiedeville - * Copyright (C) 2009-2016 Laurent Destailleur + * Copyright (C) 2009-2017 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 @@ -210,7 +210,9 @@ table.listofchoices, tr.listofchoices, td.listofchoices { tr.listofchoices { height: 42px; } - +.listofchoicesdesc { + color: #999 !important; +} .blinkwait { font-weight: bold; text-decoration:blink !important; @@ -244,9 +246,8 @@ font.warning { div.error { color: #550000; font-weight: bold; - padding: 0.2em 0.2em 0.2em 0.2em; + padding: 0.2em 0.2em 0.2em 0; margin: 0.5em 0 0.5em 0; - border: 1px solid #6C7C8B; } font.error { color: #550000; diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 2b8f57d9d3c..cdd639ad50b 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -45,13 +45,13 @@ dolibarr_install_syslog("--- fileconf: entering fileconf.php page"); // install.forced.php into directory htdocs/install (This is the case with some wizard // installer like DoliWamp, DoliMamp or DoliBuntu). // We first init "forced values" to nothing. -if (! isset($force_install_noedit)) $force_install_noedit=''; // 1=To block var specific to distrib, 2 to block all technical parameters +if (! isset($force_install_noedit)) $force_install_noedit=''; // 1=To block vars specific to distrib, 2 to block all technical parameters if (! isset($force_install_type)) $force_install_type=''; if (! isset($force_install_dbserver)) $force_install_dbserver=''; if (! isset($force_install_port)) $force_install_port=''; if (! isset($force_install_database)) $force_install_database=''; -if (! isset($force_install_prefix)) $force_install_prefix=''; -if (! isset($force_install_createdatabase)) $force_install_createdatabase=''; +if (! isset($force_install_prefix)) $force_install_prefix=''; +if (! isset($force_install_createdatabase)) $force_install_createdatabase=''; if (! isset($force_install_databaselogin)) $force_install_databaselogin=''; if (! isset($force_install_databasepass)) $force_install_databasepass=''; if (! isset($force_install_databaserootlogin)) $force_install_databaserootlogin=''; @@ -324,7 +324,7 @@ if (! empty($force_install_message)) ?> '."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''; +print "\n"; +print ''."\n"; +if (! empty($conf->paypal->enabled)) +{ + print ''."\n"; + print ''."\n"; + print ''."\n"; +} +print ''."\n"; +print ''."\n"; +print "\n"; + +print ''."\n"; + +// Show logo (search order: logo defined by PAYBOX_LOGO_suffix, then PAYBOX_LOGO, then small company logo, large company logo, theme logo, common logo) +$width=0; +// Define logo and logosmall +$logosmall=$mysoc->logo_small; +$logo=$mysoc->logo; +$paramlogo='PAYMENT_LOGO_'.$suffix; +if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo; +else if (! empty($conf->global->PAYMENT_LOGO)) $logosmall=$conf->global->PAYBOX_LOGO; +//print ''."\n"; +// Define urllogo +$urllogo=''; +if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) +{ + $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('thumbs/'.$logosmall); +} +elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) +{ + $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode($logo); + $width=96; +} +// Output html code for logo +if ($urllogo) +{ + print ''; + print ''; + print ''."\n"; +} + +// Output introduction text +$text=''; +if (! empty($conf->global->PAYPAL_NEWFORM_TEXT)) +{ + $langs->load("members"); + if (preg_match('/^\((.*)\)$/',$conf->global->PAYPAL_NEWFORM_TEXT,$reg)) $text.=$langs->trans($reg[1])."
\n"; + else $text.=$conf->global->PAYPAL_NEWFORM_TEXT."
\n"; + $text=''."\n"; +} +if (empty($text)) +{ + $text.=''."\n"; + $text.=''."\n"; +} +print $text; + +// Output payment summary form +print ''."\n"; + +print '

'.$text.'

'.$langs->trans("WelcomeOnPaymentPage").'

'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'

'; +print ''; +print ''."\n"; + +$found=false; +$error=0; +$var=false; + +// Free payment +if (! GETPOST("source") && $valid) +{ + $found=true; + $tag=GETPOST("tag"); + $fulltag=$tag; + + // Creditor + + print ''."\n"; + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum + // as they don't exists (buyer is unknown, tag is free). +} + + +// Payment on customer order +if (GETPOST("source") == 'order' && $valid) +{ + $found=true; + $langs->load("orders"); + + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + + $order=new Commande($db); + $result=$order->fetch('',$ref); + if ($result < 0) + { + $mesg=$order->error; + $error++; + } + else + { + $result=$order->fetch_thirdparty($order->socid); + } + + $amount=$order->total_ttc; + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='ORD='.$order->ref.'.CUS='.$order->thirdparty->id; + //$fulltag.='.NAM='.strtr($order->thirdparty->name,"-"," "); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + // Creditor + + print ''."\n"; + + // Debitor + + print ''."\n"; + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // Shipping address + $shipToName=$order->thirdparty->name; + $shipToStreet=$order->thirdparty->address; + $shipToCity=$order->thirdparty->town; + $shipToState=$order->thirdparty->state_code; + $shipToCountryCode=$order->thirdparty->country_code; + $shipToZip=$order->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$order->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print 'ref.'">'."\n"; +} + + +// Payment on customer invoice +if (GETPOST("source") == 'invoice' && $valid) +{ + $found=true; + $langs->load("bills"); + + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + + $invoice=new Facture($db); + $result=$invoice->fetch('',$ref); + if ($result < 0) + { + $mesg=$invoice->error; + $error++; + } + else + { + $result=$invoice->fetch_thirdparty($invoice->socid); + } + + $amount=price2num($invoice->total_ttc - $invoice->getSommePaiement()); + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='INV='.$invoice->ref.'.CUS='.$invoice->thirdparty->id; + //$fulltag.='.NAM='.strtr($invoice->thirdparty->name,"-"," "); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + // Creditor + + print ''."\n"; + + // Debitor + + print ''."\n"; + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // Shipping address + $shipToName=$invoice->thirdparty->name; + $shipToStreet=$invoice->thirdparty->address; + $shipToCity=$invoice->thirdparty->town; + $shipToState=$invoice->thirdparty->state_code; + $shipToCountryCode=$invoice->thirdparty->country_code; + $shipToZip=$invoice->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$invoice->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print 'ref.'">'."\n"; +} + +// Payment on contract line +if (GETPOST("source") == 'contractline' && $valid) +{ + $found=true; + $langs->load("contracts"); + + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + + $contractline=new ContratLigne($db); + $result=$contractline->fetch('',$ref); + if ($result < 0) + { + $mesg=$contractline->error; + $error++; + } + else + { + if ($contractline->fk_contrat > 0) + { + $contract=new Contrat($db); + $result=$contract->fetch($contractline->fk_contrat); + if ($result > 0) + { + $result=$contract->fetch_thirdparty($contract->socid); + } + else + { + $mesg=$contract->error; + $error++; + } + } + else + { + $mesg='ErrorRecordNotFound'; + $error++; + } + } + + $amount=$contractline->total_ttc; + if ($contractline->fk_product) + { + $product=new Product($db); + $result=$product->fetch($contractline->fk_product); + + // We define price for product (TODO Put this in a method in product class) + if (! empty($conf->global->PRODUIT_MULTIPRICES)) + { + $pu_ht = $product->multiprices[$contract->thirdparty->price_level]; + $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level]; + $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level]; + } + else + { + $pu_ht = $product->price; + $pu_ttc = $product->price_ttc; + $price_base_type = $product->price_base_type; + } + + $amount=$pu_ttc; + if (empty($amount)) + { + dol_print_error('','ErrorNoPriceDefinedForThisProduct'); + exit; + } + } + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='COL='.$contractline->ref.'.CON='.$contract->ref.'.CUS='.$contract->thirdparty->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M'); + //$fulltag.='.NAM='.strtr($contract->thirdparty->name,"-"," "); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + $qty=1; + if (GETPOST('qty')) $qty=GETPOST('qty'); + + // Creditor + + print ''."\n"; + + // Debitor + + print ''."\n"; + + // Quantity + + $label=$langs->trans("Quantity"); + $qty=1; + $duration=''; + if ($contractline->fk_product) + { + if ($product->isService() && $product->duration_value > 0) + { + $label=$langs->trans("Duration"); + + // TODO Put this in a global method + if ($product->duration_value > 1) + { + $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("DurationDays"),"w"=>$langs->trans("DurationWeeks"),"m"=>$langs->trans("DurationMonths"),"y"=>$langs->trans("DurationYears")); + } + else + { + $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("DurationDay"),"w"=>$langs->trans("DurationWeek"),"m"=>$langs->trans("DurationMonth"),"y"=>$langs->trans("DurationYear")); + } + $duration=$product->duration_value.' '.$dur[$product->duration_unit]; + } + } + print ''; + print ''."\n"; + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // Shipping address + $shipToName=$contract->thirdparty->name; + $shipToStreet=$contract->thirdparty->address; + $shipToCity=$contract->thirdparty->town; + $shipToState=$contract->thirdparty->state_code; + $shipToCountryCode=$contract->thirdparty->country_code; + $shipToZip=$contract->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$contract->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print 'ref.'">'."\n"; +} + +// Payment on member subscription +if (GETPOST("source") == 'membersubscription' && $valid) +{ + $found=true; + $langs->load("members"); + + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; + + $member=new Adherent($db); + $result=$member->fetch('',$ref); + if ($result < 0) + { + $mesg=$member->error; + $error++; + } + else + { + $subscription=new Subscription($db); + } + + $amount=$subscription->total_ttc; + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='MEM='.$member->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M'); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + // Creditor + + print ''."\n"; + + // Debitor + + print ''."\n"; + + if ($member->last_subscription_date || $member->last_subscription_amount) + { + // Last subscription date + + print ''."\n"; + + // Last subscription amount + + print ''."\n"; + + if (empty($amount) && ! GETPOST('newamount')) $_GET['newamount']=$member->last_subscription_amount; + } + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // Shipping address + $shipToName=$member->getFullName($langs); + $shipToStreet=$member->address; + $shipToCity=$member->town; + $shipToState=$member->state_code; + $shipToCountryCode=$member->country_code; + $shipToZip=$member->zip; + $shipToStreet2=''; + $phoneNum=$member->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print ''."\n"; +} + + + + +if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters"); + +if ($mesg) print ''."\n"; + +print '
'.$langs->trans("ThisIsInformationOnPayment").' :
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("ThirdParty"); + print ''.$order->thirdparty->name.''; + + // Object + + $text=''.$langs->trans("PaymentOrderRef",$order->ref).''; + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("ThirdParty"); + print ''.$invoice->thirdparty->name.''; + + // Object + + $text=''.$langs->trans("PaymentInvoiceRef",$invoice->ref).''; + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("ThirdParty"); + print ''.$contract->thirdparty->name.''; + + // Object + + $text=''.$langs->trans("PaymentRenewContractId",$contract->ref,$contractline->ref).''; + if ($contractline->fk_product) + { + $text.='
'.$product->ref.($product->label?' - '.$product->label:''); + } + if ($contractline->description) $text.='
'.dol_htmlentitiesbr($contractline->description); + //if ($contractline->date_fin_validite) { + // $text.='
'.$langs->trans("DateEndPlanned").': '; + // $text.=dol_print_date($contractline->date_fin_validite); + //} + if ($contractline->date_fin_validite) + { + $text.='
'.$langs->trans("ExpiredSince").': '.dol_print_date($contractline->date_fin_validite); + } + + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$label.''.($duration?$duration:$qty).''; + print ''; + print '
'.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("Member"); + print ''; + if ($member->morphy == 'mor' && ! empty($member->societe)) print $member->societe; + else print $member->getFullName($langs); + print ''; + + // Object + + $text=''.$langs->trans("PaymentSubscription").''; + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$langs->trans("LastSubscriptionDate"); + print ''.dol_print_date($member->last_subscription_date,'day'); + print '
'.$langs->trans("LastSubscriptionAmount"); + print ''.price($member->last_subscription_amount); + print '
'.$langs->trans("Amount"); + if (empty($amount)) + { + print ' ('.$langs->trans("ToComplete"); + if (! empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) print ' - '.$langs->trans("SeeHere").''; + print ')'; + } + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + $valtoshow=GETPOST("newamount",'int'); + if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); + print ''; + print ''; + } + else { + $valtoshow=$amount; + if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); + print ''.price($valtoshow).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '

'.$mesg.'
'."\n"; +print "\n"; + +if ($found && ! $error) // We are in a management option and no error +{ + if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; + + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') + { + print '
'; + } + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') + { + print '
'; + } +} +else +{ + dol_print_error_email('ERRORNEWPAYMENTPAYPAL'); +} + +print '
'."\n"; +print ''."\n"; +print ''."\n"; +print '
'; + + +html_print_paypal_footer($mysoc,$langs); + +llxFooterPaypal(); + +$db->close(); diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php new file mode 100644 index 00000000000..70dac3c960b --- /dev/null +++ b/htdocs/public/payment/paymentko.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/public/payment/paymentko.php + * \ingroup core + * \brief File to show page after a failed payment. + * This page is called by payment system with url provided to it competed with parameter TOKEN=xxx + * This token can be used to get more informations. + * \author Laurent Destailleur + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +if (! empty($conf->paypal->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; +} + +$langs->load("main"); +$langs->load("other"); +$langs->load("dict"); +$langs->load("bills"); +$langs->load("companies"); +$langs->load("paybox"); +$langs->load("paypal"); + +$PAYPALTOKEN=GETPOST('TOKEN'); +if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); +$PAYPALPAYERID=GETPOST('PAYERID'); +if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); +$PAYPALFULLTAG=GETPOST('FULLTAG'); +if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); + +$paymentmethod=array(); +if (! empty($conf->paypal->enabled)) $paymentmethod['paypal']='paypal'; +if (! empty($conf->paybox->enabled)) $paymentmethod['paybox']='paybox'; + + +// Security check +if (empty($paymentmethod)) accessforbidden('', 0, 0, 1); + + +/* + * Actions + */ + + + + +/* + * View + */ + +dol_syslog("Callback url when a PayPal payment was canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_payment'); + +$tracepost = ""; +foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; +dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); + + +// Send an email +if (! empty($conf->paypal->enabled)) +{ + if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) + { + // Get on url call + $token = $PAYPALTOKEN; + $fulltag = $PAYPALFULLTAG; + $payerID = $PAYPALPAYERID; + // Set by newpayment.php + $paymentType = $_SESSION['PaymentType']; + $currencyCodeType = $_SESSION['currencyCodeType']; + $FinalPaymentAmt = $_SESSION["Payment_Amount"]; + // From env + $ipaddress = $_SESSION['ipaddress']; + + + $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + + $urlback=$_SERVER["REQUEST_URI"]; + $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentFailed"); + $content=$langs->transnoentitiesnoconv("NewPaypalPaymentFailed")."\ntag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($topic, $sendto, $from, $content); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + } + } +} + +$head=''; +if (! empty($conf->global->PAYMENT_CSS_URL)) $head=''."\n"; + +llxHeader($head, $langs->trans("PaymentForm")); + + +// Show ko message +print ''."\n"; +print '
'."\n"; +print $langs->trans("YourPaymentHasNotBeenRecorded")."

"; + +if (! empty($conf->global->PAYPAL_MESSAGE_KO)) print $conf->global->PAYPAL_MESSAGE_KO; +print "\n
\n"; + + +html_print_paypal_footer($mysoc,$langs); + + +llxFooter(); + +$db->close(); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php new file mode 100644 index 00000000000..ce3fcd8bb29 --- /dev/null +++ b/htdocs/public/payment/paymentok.php @@ -0,0 +1,308 @@ + + * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/public/payment/paymentok.php + * \ingroup core + * \brief File to show page after a successful payment + * This page is called by payment system with url provided to it completed with parameter TOKEN=xxx + * This token can be used to get more informations. + * \author Laurent Destailleur + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +if (! empty($conf->paypal->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; +} + +// Security check +//if (empty($conf->paypal->enabled)) accessforbidden('',0,0,1); + +$langs->load("main"); +$langs->load("other"); +$langs->load("dict"); +$langs->load("bills"); +$langs->load("companies"); +$langs->load("paybox"); +$langs->load("paypal"); + +// Clean parameters +if (! empty($conf->paypal->enabled)) +{ + $PAYPAL_API_USER=""; + if (! empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; + $PAYPAL_API_PASSWORD=""; + if (! empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; + $PAYPAL_API_SIGNATURE=""; + if (! empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; + $PAYPAL_API_SANDBOX=""; + if (! empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; + $PAYPAL_API_OK=""; + if ($urlok) $PAYPAL_API_OK=$urlok; + $PAYPAL_API_KO=""; + if ($urlko) $PAYPAL_API_KO=$urlko; + if (empty($PAYPAL_API_USER)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined"); + return -1; + } + if (empty($PAYPAL_API_PASSWORD)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined"); + return -1; + } + if (empty($PAYPAL_API_SIGNATURE)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined"); + return -1; + } +} + +$source=GETPOST('source'); +$ref=GETPOST('ref'); +$PAYPALTOKEN=GETPOST('TOKEN'); +if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); +$PAYPALPAYERID=GETPOST('PAYERID'); +if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); +$PAYPALFULLTAG=GETPOST('FULLTAG'); +if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); + +$paymentmethod=array(); +if (! empty($conf->paypal->enabled)) $paymentmethod['paypal']='paypal'; +if (! empty($conf->paybox->enabled)) $paymentmethod['paybox']='paybox'; + + +// Security check +if (empty($paymentmethod)) accessforbidden('', 0, 0, 1); + + +/* + * Actions + */ + + + +/* + * View + */ + +dol_syslog("Callback url when a payment was done. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_payment'); + +$tracepost = ""; +foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; +dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); + +$head=''; +if (! empty($conf->global->PAYMENT_CSS_URL)) $head=''."\n"; + +llxHeader($head, $langs->trans("PaymentForm")); + + +// Show message +print ''."\n"; +print '
'."\n"; + +if (! empty($conf->paypal->enabled)) +{ + if ($PAYPALTOKEN) + { + // Get on url call + $token = $PAYPALTOKEN; + $fulltag = $PAYPALFULLTAG; + $payerID = $PAYPALPAYERID; + // Set by newpayment.php + $paymentType = $_SESSION['PaymentType']; + $currencyCodeType = $_SESSION['currencyCodeType']; + $FinalPaymentAmt = $_SESSION["Payment_Amount"]; + // From env + $ipaddress = $_SESSION['ipaddress']; + + dol_syslog("Call paymentok with token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_paypal'); + + + // Validate record + if (! empty($paymentType)) + { + dol_syslog("We call GetExpressCheckoutDetails", LOG_DEBUG, 0, '_payment'); + $resArray=getDetails($token); + //var_dump($resarray); + + dol_syslog("We call DoExpressCheckoutPayment token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_payment'); + $resArray=confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag); + + $ack = strtoupper($resArray["ACK"]); + if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") + { + $object = new stdClass(); + + $object->source = $source; + $object->ref = $ref; + $object->payerID = $payerID; + $object->fulltag = $fulltag; + $object->resArray = $resArray; + + // resArray was built from a string like that + // TOKEN=EC%2d1NJ057703V9359028&TIMESTAMP=2010%2d11%2d01T11%3a40%3a13Z&CORRELATIONID=1efa8c6a36bd8&ACK=Success&VERSION=56&BUILD=1553277&TRANSACTIONID=9B994597K9921420R&TRANSACTIONTYPE=expresscheckout&PAYMENTTYPE=instant&ORDERTIME=2010%2d11%2d01T11%3a40%3a12Z&AMT=155%2e57&FEEAMT=5%2e54&TAXAMT=0%2e00&CURRENCYCODE=EUR&PAYMENTSTATUS=Completed&PENDINGREASON=None&REASONCODE=None + $PAYMENTSTATUS=urldecode($resArray["PAYMENTSTATUS"]); // Should contains 'Completed' + $TRANSACTIONID=urldecode($resArray["TRANSACTIONID"]); + $TAXAMT=urldecode($resArray["TAXAMT"]); + $NOTE=urldecode($resArray["NOTE"]); + + print $langs->trans("YourPaymentHasBeenRecorded")."
\n"; + print $langs->trans("ThisIsTransactionId",$TRANSACTIONID)."

\n"; + if (! empty($conf->global->PAYPAL_MESSAGE_OK)) print $conf->global->PAYPAL_MESSAGE_OK; + + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers('PAYPAL_PAYMENT_OK',$object,$user,$langs,$conf); + if ($result < 0) { $error++; $errors=$interface->errors; } + // Fin appel triggers + + // Send an email + if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) + { + $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $urlback=$_SERVER["REQUEST_URI"]; + $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentReceived"); + $tmptag=dolExplodeIntoArray($fulltag,'.','='); + $content=""; + if (! empty($tmptag['MEM'])) + { + $langs->load("members"); + $url=$urlwithroot."/adherents/card_subscriptions.php?rowid=".$tmptag['MEM']; + $content.=$langs->trans("PaymentSubscription")."
\n"; + $content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
\n"; + $content.=$langs->trans("Link").': '.$url.''."
\n"; + } + else + { + $content.=$langs->transnoentitiesnoconv("NewPaypalPaymentReceived")."
\n"; + } + $content.="
\n"; + $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":
\n"; + $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; + $content.="tag=".$fulltag." token=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + + $ishtml=dol_textishtml($content); // May contain urls + + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + } + } + } + else + { + //Display a user friendly Error on the page using any of the following error information returned by PayPal + $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); + $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); + $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); + $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); + + echo $langs->trans('DoExpressCheckoutPaymentAPICallFailed') . "
\n"; + echo $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
\n"; + echo $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."
\n"; + echo $langs->trans('ErrorCode') . ": " . $ErrorCode."
\n"; + echo $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."
\n"; + + if ($mysoc->email) echo "\nPlease, send a screenshot of this page to ".$mysoc->email."
\n"; + + // Send an email + if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) + { + $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $urlback=$_SERVER["REQUEST_URI"]; + $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("ValidationOfPaypalPaymentFailed"); + $content=""; + $content.=$langs->transnoentitiesnoconv("PaypalConfirmPaymentPageWasCalledButFailed")."\n"; + $content.="\n"; + $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":\n"; + $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."\n"; + $content.="tag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + + $ishtml=dol_textishtml($content); // May contain urls + + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + } + } + } + } + else + { + dol_print_error('','Session expired'); + } + } +} +else +{ + // No TOKEN parameter in URL + dol_print_error('','No TOKEN parameter in URL'); +} + +print "\n
\n"; + +html_print_paypal_footer($mysoc,$langs); + + +llxFooter(); + +$db->close(); diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index e1dc1c12671..32d13356654 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -83,7 +83,7 @@ if (empty($reshook)) } // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $actioncode=''; $search_agenda_label=''; @@ -180,12 +180,6 @@ if ($socid > 0) print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); - // List of todo actions - //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); - - // List of done actions - //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode); - // List of all actions $filters=array(); $filters['search_agenda_label']=$search_agenda_label; diff --git a/htdocs/theme/eldy/img/save.png b/htdocs/theme/eldy/img/save.png new file mode 100644 index 00000000000..eca2d92eccc Binary files /dev/null and b/htdocs/theme/eldy/img/save.png differ diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 4e72843eae3..ebb3ee4184c 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -253,7 +253,7 @@ a.tab { font-weight: bold !important; } a:link, a:visited, a:hover, a:active { font-family: ; font-weight: normal; color: rgb(); text-decoration: none; } a:hover { text-decoration: underline; color: rgb(); } a.commonlink { color: rgb() !important; text-decoration: none; } - +th.liste_titre a div div:hover, th.liste_titre_sel a div div:hover { text-decoration: underline; } input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select { background-color: #FFF; } @@ -1973,6 +1973,10 @@ div.tabBar { width: auto; background: rgb(); } +div.tabBar div.titre { + padding-top: 10px; +} + div.tabBarWithBottom { padding-bottom: 18px; border-bottom: 1px solid #aaa; diff --git a/htdocs/theme/md/img/save.png b/htdocs/theme/md/img/save.png new file mode 100644 index 00000000000..eca2d92eccc Binary files /dev/null and b/htdocs/theme/md/img/save.png differ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 64e73c144ba..7e8a4cd22ad 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1992,6 +1992,9 @@ div.tabBar { padding-bottom: 12px; border-bottom: 1px solid #aaa; } +div.tabBar div.titre { + padding-top: 10px; +} div.tabBarWithBottom { padding-bottom: 18px; border-bottom: 1px solid #aaa; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a3006d6ebcd..f23c8aca0b6 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -376,7 +376,7 @@ class User extends CommonObject { if (! empty($obj->page) && ! empty($obj->type) && ! empty($obj->param)) { - $user->default_values[$obj->page][$obj->type][$obj->param]=$obj->value; + $this->default_values[$obj->page][$obj->type][$obj->param]=$obj->value; } } $this->db->free($resql); @@ -387,7 +387,7 @@ class User extends CommonObject return -3; } } - + return 1; } diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php index 51a61d90112..a77079c94a6 100644 --- a/htdocs/websites/class/website.class.php +++ b/htdocs/websites/class/website.class.php @@ -73,10 +73,6 @@ class Website extends CommonObject * @var mixed */ public $date_creation; - /** - * @var mixed - */ - public $date_modification; /** * @var mixed */ @@ -123,7 +119,6 @@ class Website extends CommonObject $error = 0; // Clean parameters - if (isset($this->entity)) { $this->entity = trim($this->entity); } @@ -136,36 +131,30 @@ class Website extends CommonObject if (isset($this->status)) { $this->status = trim($this->status); } - - + if (empty($this->date_creation)) $this->date_creation = dol_now(); // Check parameters // Put here code to add control on parameters values // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql.= 'entity,'; $sql.= 'ref,'; $sql.= 'description,'; $sql.= 'status,'; $sql.= 'fk_default_home,'; $sql.= 'virtualhost,'; - $sql.= 'date_creation,'; - $sql.= 'date_modification'; - + $sql.= 'fk_user_create'; + $sql.= 'date_creation'; $sql .= ') VALUES ('; - $sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).','; $sql .= ' '.(! isset($this->ref)?'NULL':"'".$this->db->escape($this->ref)."'").','; $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").','; $sql .= ' '.(! isset($this->status)?'NULL':$this->status).','; $sql .= ' '.(! isset($this->fk_default_home)?'NULL':$this->fk_default_home).','; $sql .= ' '.(! isset($this->virtualhost)?'NULL':$this->virtualhost).','; - $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").','; - $sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_modification)."'"); - - + $sql .= ' '.(! isset($this->fk_user_create)?$user->id:$this->fk_user_create).','; + $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'"); $sql .= ')'; $this->db->begin(); @@ -223,8 +212,9 @@ class Website extends CommonObject $sql .= " t.status,"; $sql .= " t.fk_default_home,"; $sql .= " t.virtualhost,"; + $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; - $sql .= " t.date_modification,"; $sql .= " t.tms"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; if (null !== $ref) { @@ -247,11 +237,10 @@ class Website extends CommonObject $this->status = $obj->status; $this->fk_default_home = $obj->fk_default_home; $this->virtualhost = $obj->virtualhost; + $this->fk_user_create = $obj->fk_user_create; + $this->fk_user_modif = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date_modification = $this->db->jdate($obj->date_modification); $this->tms = $this->db->jdate($obj->tms); - - } $this->db->free($resql); @@ -292,8 +281,9 @@ class Website extends CommonObject $sql .= " t.status,"; $sql .= " t.fk_default_home,"; $sql .= " t.virtualhost,"; + $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; - $sql .= " t.date_modification,"; $sql .= " t.tms"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; @@ -331,8 +321,9 @@ class Website extends CommonObject $line->status = $obj->status; $line->fk_default_home = $obj->fk_default_home; $line->virtualhost = $obj->virtualhost; + $this->fk_user_create = $obj->fk_user_create; + $this->fk_user_modif = $obj->fk_user_modif; $line->date_creation = $this->db->jdate($obj->date_creation); - $line->date_modification = $this->db->jdate($obj->date_modification); $line->tms = $this->db->jdate($obj->tms); $this->records[$line->id] = $line; @@ -377,25 +368,20 @@ class Website extends CommonObject $this->status = trim($this->status); } - - // Check parameters // Put here code to add a control on parameters values // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - $sql .= ' entity = '.(isset($this->entity)?$this->entity:"null").','; $sql .= ' ref = '.(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").','; $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").','; $sql .= ' status = '.(isset($this->status)?$this->status:"null").','; $sql .= ' fk_default_home = '.(($this->fk_default_home > 0)?$this->fk_default_home:"null").','; $sql .= ' virtualhost = '.(($this->virtualhost != '')?"'".$this->db->escape($this->virtualhost)."'":"null").','; + $sql .= ' fk_user_modif = '.(! isset($this->fk_user_modif) ? $user->id : $this->fk_user_modif).','; $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; - $sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'"); - - $sql .= ' WHERE rowid=' . $this->id; $this->db->begin(); @@ -631,6 +617,8 @@ class Website extends CommonObject */ public function initAsSpecimen() { + global $user; + $this->id = 0; $this->entity = 1; @@ -639,8 +627,9 @@ class Website extends CommonObject $this->status = ''; $this->fk_default_home = null; $this->virtualhost = 'http://myvirtualhost'; + $this->fk_user_create = $user->id; + $this->fk_user_modif = $user->id; $this->date_creation = dol_now(); - $this->date_modification = dol_now(); $this->tms = dol_now(); diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 883b6495c53..c80d20fe44b 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -181,7 +181,7 @@ class WebsitePage extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object + * @param int $id Id object. If this is 0, the default page of website_id will be used, if not defined, the first one. found * @param string $website_id Web site id * @param string $page Page name * @@ -205,13 +205,16 @@ class WebsitePage extends CommonObject $sql .= " t.tms as date_modification"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + //$sql .= ' WHERE entity IN ('.getEntity('website', 1).')'; // entity is on website level + $sql .= ' WHERE 1 = 1'; if (null !== $website_id) { - $sql .= ' WHERE t.fk_website = ' . '\'' . $website_id . '\''; - $sql .= ' AND t.pageurl = ' . '\'' . $page . '\''; + $sql .= " AND t.fk_website = '" . $this->db->escape($website_id) . "'"; + if ($page) $sql .= " AND t.pageurl = '" . $this->db->escape($page) . "'"; } else { - $sql .= ' WHERE t.rowid = ' . $id; + $sql .= ' AND t.rowid = ' . $id; } - + $sql .= $this->db->plimit(1); + $resql = $this->db->query($sql); if ($resql) { $numrows = $this->db->num_rows($resql); diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index b55f81f5b7f..b78a172e01f 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -438,16 +438,34 @@ if ($action == 'updatemeta') // Update page if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview')) { - $db->begin(); $object->fetch(0, $website); + /*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite')) + { + $object->virtualhost = GETPOST('previewsite', 'alpha'); + $object->update($user); + }*/ + $objectpage->fk_website = $object->id; - $res = $objectpage->fetch($pageid, $object->fk_website); + if ($pageid > 0) + { + $res = $objectpage->fetch($pageid); + } + else + { + $res = $objectpage->fetch($object->fk_default_home); + if (! $res > 0) + { + $res = $objectpage->fetch(0, $object->fk_website); + } + } if ($res > 0) { if ($action == 'updatecontent') { + $db->begin(); + $objectpage->content = GETPOST('PAGE_CONTENT'); // Clean data. We remove all the head section. @@ -632,7 +650,7 @@ if (count($object->records) > 0) // List of websites print '
'; $out=''; - $out.=''; if (empty($object->records)) $out.=''; // Loop on each sites $i=0; @@ -654,9 +672,9 @@ if (count($object->records) > 0) if ($website) { - $realurl=$urlwithroot.'/public/websites/index.php?website='.$website; + $virtualurl=''; $dataroot=DOL_DATA_ROOT.'/websites/'.$website; - if (! empty($object->virtualhost)) $realurl=$object->virtualhost; + if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; } if ($website && $action == 'preview') @@ -680,20 +698,23 @@ if (count($object->records) > 0) if ($action == 'preview') { print '
'; - print ''; + print ''; //print ''; $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); print $form->textwithpicto('', $htmltext); print '
'; - $urlext=$realurl; - $urlint=DOL_URL_ROOT.'/public/websites/index.php?website='.$website; - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $urlext), 1, 'preview_ext'); - print ''; + $urlext=$virtualurl; + $urlint=$urlwithroot.'/public/websites/index.php?website='.$website; + //if (! empty($object->virtualhost)) + //{ + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; + //} - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $urlint), 1, 'preview'); + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); print ''; } @@ -803,13 +824,22 @@ if (count($object->records) > 0) print $form->textwithpicto('', $htmltext); print '
'; - $urlext=$realurl.'/'.$pagealias.'.php'; - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $urlext), 1, 'preview_ext'); - print ''; + if (! empty($object->virtualhost)) + { + $urlext=$virtualurl.'/'.$pagealias.'.php'; + print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; + } + else + { + print ''; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; + } - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage), 1, 'preview'); + print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); print ''; // View page in new Tab //print '';