From cb03b2f3074965ac6cd5f9e8f9e5b593400cbfdb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Nov 2017 18:14:29 +0100 Subject: [PATCH] NEW Can sort joined files on thirdparty and user card. --- htdocs/core/ajax/row.php | 4 ++-- htdocs/core/class/html.formfile.class.php | 8 +++---- htdocs/core/photos_resize.php | 24 ++++++++++++++++--- .../tpl/document_actions_post_headers.tpl.php | 2 +- htdocs/societe/document.php | 2 +- htdocs/user/class/user.class.php | 13 +++++----- htdocs/user/document.php | 2 +- 7 files changed, 37 insertions(+), 18 deletions(-) diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 6e358bdbd88..71a5a0aac88 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -63,9 +63,9 @@ if ((isset($_POST['roworder']) && ! empty($_POST['roworder'])) && (isset($_POST[ $row->table_element_line = $table_element_line; $row->fk_element = $fk_element; $row->id = $element_id; - $row->line_ajaxorder($newrowordertab); + $row->line_ajaxorder($newrowordertab); // This update field rank or position in table table_element_line - // Reorder line to have position of chilren lines sharing same counter than parent lines + // Reorder line to have position of children lines sharing same counter than parent lines // This should be useless because there is no need to have children sharing same counter than parent, but well, it's cleaner into database. if (in_array($fk_element,array('fk_facture','fk_propal','fk_commande'))) { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index bc162abd170..4c354b66107 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1042,10 +1042,10 @@ class FormFile { completeFileArrayWithDatabaseInfo($filearray, $relativedir); - /*var_dump($sortfield); - var_dump($sortorder);*/ - if ($sortfield && $sortorder) + //var_dump($sortfield.' - '.$sortorder); + if ($sortfield && $sortorder) // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name) { + //var_dump($sortfield); $filearray=dol_sort_array($filearray, $sortfield, $sortorder); } //var_dump($filearray); @@ -1139,7 +1139,7 @@ class FormFile if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service'; $disablecrop=1; - if (in_array($modulepart, array('product','produit','service','expensereport','holiday','project','user'))) $disablecrop=0; + if (in_array($modulepart, array('societe','product','produit','service','expensereport','holiday','project','user'))) $disablecrop=0; if (! $disablecrop && image_format_supported($file['name']) > 0) { diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index fcedc2a4e11..9a11523f39b 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -67,9 +67,15 @@ elseif ($modulepart == 'expensereport') } elseif ($modulepart == 'user') { - $result=restrictedArea($user,'user',$id,'user'); - if (! $user->rights->user->user->lire) accessforbidden(); - $accessallowed=1; + $result=restrictedArea($user,'user',$id,'user'); + if (! $user->rights->user->user->lire) accessforbidden(); + $accessallowed=1; +} +elseif ($modulepart == 'societe') +{ + $result=restrictedArea($user,'societe',$id,'societe'); + if (! $user->rights->societe->lire) accessforbidden(); + $accessallowed=1; } // Security: @@ -115,6 +121,17 @@ elseif ($modulepart == 'holiday') $dir=$conf->holiday->dir_output; // By default } } +elseif ($modulepart == 'societe') +{ + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + $object = new Societe($db); + if ($id > 0) + { + $result = $object->fetch($id); + if ($result <= 0) dol_print_error($db,'Failed to load object'); + $dir=$conf->societe->dir_output; + } +} elseif ($modulepart == 'user') { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -145,6 +162,7 @@ if (empty($backtourl)) else if (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); else if (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + else if (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); } diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index da1cb9658a0..10650364543 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -79,7 +79,7 @@ $formfile->form_attach_new_file( ); $disablemove=1; -if ($modulepart == 'product' || $modulepart == 'produit') $disablemove=0; // Drag and drop for up and down allowed on product +if (in_array($modulepart, array('product', 'produit', 'societe', 'user'))) $disablemove=0; // Drag and drop for up and down allowed on product // List of document $formfile->list_of_documents( diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index fbfd931b69b..be549d6cac5 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -58,7 +58,7 @@ $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; +if (! $sortfield) $sortfield="position_name"; $object = new Societe($db); if ($id > 0 || ! empty($ref)) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index b9e7378bd31..565e1f014b7 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -40,6 +40,7 @@ class User extends CommonObject { public $element='user'; public $table_element='user'; + public $fk_element='fk_user'; public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $id=0; @@ -53,17 +54,17 @@ class User extends CommonObject public $job; public $signature; public $address; - public $zip; - public $town; - public $state_id; - public $state_code; - public $state; + public $zip; + public $town; + public $state_id; + public $state_code; + public $state; public $office_phone; public $office_fax; public $user_mobile; public $admin; public $login; - public $api_key; + public $api_key; public $entity; //! Clear password in memory diff --git a/htdocs/user/document.php b/htdocs/user/document.php index 27cf4eb757a..ff7fe9b5ab9 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -81,7 +81,7 @@ $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; +if (! $sortfield) $sortfield="position_name"; $object = new User($db); if ($id > 0 || ! empty($ref))