28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
33$langs->loadLangs(array(
"products",
"other"));
36$action =
GETPOST(
'action',
'aZ09');
37$modulepart =
GETPOST(
'modulepart',
'alpha') ?
GETPOST(
'modulepart',
'alpha') :
'produit|service';
38$original_file =
GETPOST(
"file");
39$backtourl =
GETPOST(
'backtourl');
40$cancel =
GETPOST(
'cancel',
'alpha');
42$file =
GETPOST(
'file',
'alpha');
44$website =
GETPOST(
'website',
'alpha');
48if (empty($modulepart)) {
52if ($modulepart ==
'produit' || $modulepart ==
'product' || $modulepart ==
'service' || $modulepart ==
'produit|service') {
53 $result =
restrictedArea($user,
'produit|service', $id,
'product&product');
54 if ($modulepart ==
'produit|service' && (!$user->hasRight(
'produit',
'lire') && !$user->hasRight(
'service',
'lire'))) {
58} elseif ($modulepart ==
'project') {
60 if (!$user->hasRight(
'projet',
'lire')) {
64} elseif ($modulepart ==
'bom') {
66 if (!$user->hasRight(
'bom',
'read')) {
70} elseif ($modulepart ==
'member') {
71 $result =
restrictedArea($user,
'adherent', $id,
'',
'',
'fk_soc',
'rowid');
72 if (!$user->hasRight(
'adherent',
'lire')) {
76} elseif ($modulepart ==
'user') {
77 $result =
restrictedArea($user, $modulepart, $id, $modulepart, $modulepart);
78 if (!$user->hasRight(
'user',
'user',
'lire')) {
82} elseif ($modulepart ==
'tax') {
83 $result =
restrictedArea($user, $modulepart, $id,
'chargesociales',
'charges');
84 if (!$user->hasRight(
'tax',
'charges',
'lire')) {
88} elseif ($modulepart ==
'bank') {
90 if (!$user->hasRight(
'banque',
'lire')) {
94} elseif ($modulepart ==
'medias') {
95 $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write);
100} elseif ($modulepart ==
'facture_fourn' || $modulepart ==
'facture_fournisseur') {
101 $result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture');
102 if (!$user->hasRight(
'fournisseur',
'facture',
'lire')) {
109 if (!$user->hasRight($modulepart,
'read') && !$user->hasRight($modulepart,
'lire')) {
117if (!$accessallowed) {
123if ($modulepart ==
'produit' || $modulepart ==
'product' || $modulepart ==
'service' || $modulepart ==
'produit|service') {
124 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
127 $result = $object->fetch($id);
131 $dir = $conf->product->multidir_output[$object->entity];
133 $dir = $conf->product->multidir_output[$object->entity];
136 $dir = $conf->service->multidir_output[$object->entity];
139} elseif ($modulepart ==
'project') {
140 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
143 $result = $object->fetch($id);
147 $dir = $conf->project->multidir_output[$object->entity];
149} elseif ($modulepart ==
'propal') {
150 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
151 $object =
new Propal($db);
153 $result = $object->fetch($id);
157 $dir = $conf->propal->multidir_output[$object->entity];
159} elseif ($modulepart ==
'holiday') {
160 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
163 $result = $object->fetch($id);
167 $dir = $conf->$modulepart->dir_output;
169} elseif ($modulepart ==
'member') {
170 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
173 $result = $object->fetch($id);
177 $dir = $conf->adherent->dir_output;
179} elseif ($modulepart ==
'societe') {
180 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
183 $result = $object->fetch($id);
187 $dir = $conf->$modulepart->dir_output;
189} elseif ($modulepart ==
'user') {
190 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
191 $object =
new User($db);
193 $result = $object->fetch($id);
197 $dir = $conf->$modulepart->dir_output;
199} elseif ($modulepart ==
'expensereport') {
200 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
203 $result = $object->fetch($id);
207 $dir = $conf->expensereport->dir_output;
209} elseif ($modulepart ==
'tax') {
210 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
213 $result = $object->fetch($id);
217 $dir = $conf->$modulepart->dir_output;
219} elseif ($modulepart ==
'ticket') {
220 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
221 $object =
new Ticket($db);
223 $result = $object->fetch($id);
227 $dir = $conf->$modulepart->dir_output;
229} elseif ($modulepart ==
'bom') {
230 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
231 $object =
new BOM($db);
233 $result = $object->fetch($id);
237 $dir = $conf->$modulepart->dir_output;
239} elseif ($modulepart ==
'mrp') {
240 require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
241 $object =
new Mo($db);
243 $result = $object->fetch($id);
247 $dir = $conf->$modulepart->dir_output;
249} elseif ($modulepart ==
'bank') {
250 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
253 $result = $object->fetch($id);
257 $dir = $conf->bank->dir_output;
259} elseif ($modulepart ==
'facture') {
260 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
263 $result = $object->fetch($id);
267 $dir = $conf->$modulepart->dir_output;
269} elseif ($modulepart ==
'facture_fourn' || $modulepart ==
'facture_fournisseur') {
270 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
273 $result = $object->fetch($id);
277 $dir = $conf->fournisseur->dir_output.
'/facture';
279} elseif ($modulepart ==
'medias') {
280 $dir = $dolibarr_main_data_root.
'/'.$modulepart;
282 print
'Bug: Action crop for modulepart = '.$modulepart.
' is not supported yet by photos_resize.php.';
285if (empty($backtourl)) {
288 if (in_array($modulepart, array(
'product',
'produit',
'service',
'produit|service'))) {
289 $backtourl = DOL_URL_ROOT.
"/product/document.php?id=".((int) $id).
'&file='.urlencode($file);
290 } elseif (in_array($modulepart, array(
'expensereport'))) {
291 $backtourl = DOL_URL_ROOT.
"/expensereport/document.php?id=".((int) $id).
'&file='.urlencode($file);
292 } elseif (in_array($modulepart, array(
'holiday'))) {
293 $backtourl = DOL_URL_ROOT.
"/holiday/document.php?id=".((int) $id).
'&file='.urlencode($file);
294 } elseif (in_array($modulepart, array(
'member'))) {
295 $backtourl = DOL_URL_ROOT.
"/adherents/document.php?id=".((int) $id).
'&file='.urlencode($file);
296 } elseif (in_array($modulepart, array(
'project'))) {
297 $backtourl = DOL_URL_ROOT.
"/projet/document.php?id=".((int) $id).
'&file='.urlencode($file);
298 } elseif (in_array($modulepart, array(
'propal'))) {
299 $backtourl = DOL_URL_ROOT.
"/comm/propal/document.php?id=".((int) $id).
'&file='.urlencode($file);
300 } elseif (in_array($modulepart, array(
'societe'))) {
301 $backtourl = DOL_URL_ROOT.
"/societe/document.php?id=".((int) $id).
'&file='.urlencode($file);
302 } elseif (in_array($modulepart, array(
'tax'))) {
303 $backtourl = DOL_URL_ROOT.
"/compta/sociales/document.php?id=".((int) $id).
'&file='.urlencode($file);
304 } elseif (in_array($modulepart, array(
'ticket'))) {
305 $backtourl = DOL_URL_ROOT.
"/ticket/document.php?id=".((int) $id).
'&file='.urlencode($file);
306 } elseif (in_array($modulepart, array(
'user'))) {
307 $backtourl = DOL_URL_ROOT.
"/user/document.php?id=".((int) $id).
'&file='.urlencode($file);
308 } elseif (in_array($modulepart, array(
'facture'))) {
309 $backtourl = DOL_URL_ROOT.
"/compta/facture/document.php?id=".((int) $id).
'&file='.urlencode($file);
310 } elseif (in_array($modulepart, array(
'facture_fourn',
'facture_fournisseur'))) {
311 $backtourl = DOL_URL_ROOT.
"/fourn/facture/document.php?id=".((int) $id).
'&file='.urlencode($file);
312 } elseif (in_array($modulepart, array(
'bank')) && preg_match(
'/\/statement\/([^\/]+)\//', $file, $regs)) {
314 $backtourl = DOL_URL_ROOT.
"/compta/bank/account_statement_document.php?id=".((int) $id).
'&num='.urlencode($num).
'&file='.urlencode($file);
315 } elseif (in_array($modulepart, array(
'bank'))) {
316 $backtourl = DOL_URL_ROOT.
"/compta/bank/document.php?id=".((int) $id).
'&file='.urlencode($file);
317 } elseif (in_array($modulepart, array(
'mrp'))) {
318 $backtourl = DOL_URL_ROOT.
"/mrp/mo_document.php?id=".((int) $id).
'&file='.urlencode($file);
319 } elseif (in_array($modulepart, array(
'medias'))) {
320 $section_dir = dirname($file);
321 if (!preg_match(
'/\/$/', $section_dir)) {
324 $backtourl = DOL_URL_ROOT.
'/website/index.php?action=file_manager'.($website ?
'&website='.urlencode($website) :
'').
'§ion_dir='.urlencode($section_dir);
327 $backtourl = DOL_URL_ROOT.
"/".$modulepart.
"/".$modulepart.
"_document.php?id=".((int) $id).
'&file='.urlencode($file);
338 header(
"Location: ".$backtourl);
341 dol_print_error(
'',
'Cancel on photo_resize with a not supported value of modulepart='.$modulepart);
346if ($action ==
'confirm_resize' && GETPOSTISSET(
"file") && GETPOSTISSET(
"sizex") && GETPOSTISSET(
"sizey")) {
352 $fullpath = $dir.
"/".$original_file;
356 if ($result == $fullpath) {
358 if (is_object($object)) {
359 $object->addThumbs($fullpath);
363 $rel_filename = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $fullpath);
364 $rel_filename = preg_replace(
'/^[\\/]/',
'', $rel_filename);
366 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
368 $result = $ecmfile->fetch(0,
'', $rel_filename);
370 $filename = basename($rel_filename);
371 $rel_dir = dirname($rel_filename);
372 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
373 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
376 $result = $ecmfile->update($user);
377 } elseif ($result == 0) {
378 $filename = basename($rel_filename);
379 $rel_dir = dirname($rel_filename);
380 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
381 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
383 $ecmfile->filepath = $rel_dir;
384 $ecmfile->filename = $filename;
386 $ecmfile->fullpath_orig = $fullpath;
387 $ecmfile->gen_or_uploaded =
'unknown';
388 $ecmfile->description =
'';
389 $ecmfile->keywords =
'';
390 $result = $ecmfile->create($user);
394 $result = $ecmfile->create($user);
398 header(
"Location: ".$backtourl);
401 dol_print_error(
'',
'confirm_resize on photo_resize without backtourl defined for modulepart='.$modulepart);
406 $_GET[
'file'] = $_POST[
"file"];
412if ($action ==
'confirm_crop') {
414 print
'Bug: Value for $dir could not be defined.';
417 $fullpath = $dir.
"/".$original_file;
421 if ($result == $fullpath) {
422 if (is_object($object)) {
423 $object->addThumbs($fullpath);
427 $rel_filename = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $fullpath);
428 $rel_filename = preg_replace(
'/^[\\/]/',
'', $rel_filename);
430 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
432 $result = $ecmfile->fetch(0,
'', $rel_filename);
434 $filename = basename($rel_filename);
435 $rel_dir = dirname($rel_filename);
436 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
437 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
440 $result = $ecmfile->update($user);
441 } elseif ($result == 0) {
442 $filename = basename($rel_filename);
443 $rel_dir = dirname($rel_filename);
444 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
445 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
447 $ecmfile->filepath = $rel_dir;
448 $ecmfile->filename = $filename;
450 $ecmfile->fullpath_orig = $fullpath;
451 $ecmfile->gen_or_uploaded =
'unknown';
452 $ecmfile->description =
'';
453 $ecmfile->keywords =
'';
454 $result = $ecmfile->create($user);
461 header(
"Location: ".$backtourl);
464 dol_print_error(
'',
'confirm_crop on photo_resize without backtourl defined for modulepart='.$modulepart);
469 $_GET[
'file'] = $_POST[
"file"];
480$title = $langs->trans(
"ImageEditor");
481$morejs = array(
'/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js',
'/core/js/lib_photosresize.js');
482$morecss = array(
'/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css');
484llxHeader($head, $title,
'',
'', 0, 0, $morejs, $morecss);
490$height = $infoarray[
'height'];
491$width = $infoarray[
'width'];
492print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"CurrentInformationOnImage").
': </span>';
493print
'<span class="opacitymedium">';
494print $langs->trans(
"Width").
': <strong>'.$width.
'</strong> x '.$langs->trans(
"Height").
': <strong>'.$height.
'</strong>';
504print
'<!-- Form to resize -->'.
"\n";
505print
'<form name="redim_file" action="'.$_SERVER[
"PHP_SELF"].
'?id='.((int) $id).($num ?
'&num='.urlencode($num) :
'').
'" method="POST">';
506print
'<input type="hidden" name="token" value="'.newToken().
'">';
507print
'<input type="hidden" name="backtourl" value="'.$backtourl.
'">';
509print
'<fieldset id="redim_file">';
510print
'<legend>'.$langs->trans(
"Resize").
'</legend>';
511print $langs->trans(
"ResizeDesc").
'<br>';
512print $langs->trans(
"NewLength").
': <input name="sizex" type="number" class="flat maxwidth50 right"> px <span class="opacitymedium">'.$langs->trans(
"or").
'</span> ';
513print $langs->trans(
"NewHeight").
': <input name="sizey" type="number" class="flat maxwidth50 right"> px <br>';
515print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'" />';
516print
'<input type="hidden" name="action" value="confirm_resize" />';
517print
'<input type="hidden" name="product" value="'.$id.
'" />';
518print
'<input type="hidden" name="modulepart" value="'.dol_escape_htmltag($modulepart).
'" />';
519print
'<input type="hidden" name="id" value="'.$id.
'" />';
521print
'<input class="button" id="submitresize" name="sendit" value="'.dol_escape_htmltag($langs->trans(
"Resize")).
'" type="submit" />';
523print
'<input type="submit" id="cancelresize" name="cancel" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" />';
524print
'</fieldset>'.
"\n";
536if (!empty($conf->use_javascript_ajax)) {
538 $height = $infoarray[
'height'];
539 $width = $infoarray[
'width'];
540 $widthforcrop = $width;
541 $refsizeforcrop =
'orig';
545 if (!empty($_SESSION[
'dol_screenwidth'])) {
546 $widthforcroporigin = $widthforcrop;
547 while ($widthforcrop > round($_SESSION[
'dol_screenwidth'] / 1.5)) {
549 $ratioforcrop = 2 * $ratioforcrop;
550 $widthforcrop = floor($widthforcroporigin / $ratioforcrop);
551 $refsizeforcrop =
'screenwidth';
555 print
'<!-- Form to crop -->'.
"\n";
556 print
'<fieldset id="redim_file">';
557 print
'<legend>'.$langs->trans(
"Crop").
'</legend>';
558 print $langs->trans(
"DefineNewAreaToPick").
'...<br>';
559 print
'<br><div class="center">';
561 if (empty($conf->dol_no_mouse_hover)) {
562 print
'<div style="border: 1px solid #888888; width: '.$widthforcrop.
'px;">';
563 print
'<img src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$object->entity.
'&file='.urlencode($original_file).
'" alt="" id="cropbox" width="'.$widthforcrop.
'px"/>';
567 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.((int) $id).($num ?
'&num='.$num :
'').
'" method="POST">';
568 print
'<input type="hidden" name="token" value="'.newToken().
'">';
569 print
'<input type="hidden" name="backtourl" value="'.$backtourl.
'">';
571 <div class="jc_coords">
572 '.$langs->trans(
"NewSizeAfterCropping").
':
573 <label>X1=<input type="number" class="flat maxwidth50" id="x" name="x" /></label>
574 <label>Y1=<input type="number" class="flat maxwidth50" id="y" name="y" /></label>
575 <label>X2=<input type="number" class="flat maxwidth50" id="x2" name="x2" /></label>
576 <label>Y2=<input type="number" class="flat maxwidth50" id="y2" name="y2" /></label>
577 <label>W=<input type="number" class="flat maxwidth50" id="w" name="w" /></label>
578 <label>H=<input type="number" class="flat maxwidth50" id="h" name="h" /></label>
581 <input type="hidden" id="file" name="file" value="'.
dol_escape_htmltag($original_file).
'" />
582 <input type="hidden" id="action" name="action" value="confirm_crop" />
583 <input type="hidden" id="product" name="product" value="'.
dol_escape_htmltag($id).
'" />
584 <input type="hidden" id="dol_screenwidth" name="dol_screenwidth" value="'.$_SESSION[
'dol_screenwidth'].
'" />
585 <input type="hidden" id="refsizeforcrop" name="refsizeforcrop" value="'.$refsizeforcrop.
'" />
586 <input type="hidden" id="ratioforcrop" name="ratioforcrop" value="'.$ratioforcrop.
'" /><!-- value in field used by js/lib/lib_photoresize.js -->
587 <input type="hidden" id="imagewidth" name="imagewidth" value="'.$width.
'" /><!-- value in field used by js/lib/lib_photoresize.js -->
588 <input type="hidden" id="imageheight" name="imageheight" value="'.$height.
'" /><!-- value in field used by js/lib/lib_photoresize.js -->
592 <input type="submit" id="submitcrop" name="submitcrop" class="button" value="'.
dol_escape_htmltag($langs->trans(
"Crop")).
'" />
594 <input type="submit" id="cancelcrop" name="cancel" class="button button-cancel" value="'.
dol_escape_htmltag($langs->trans(
"Cancel")).
'" />
597 $langs->load(
"other");
598 print
'<div class="opacitymedium">'.$langs->trans(
"FeatureNotAvailableOnDevicesWithoutMouse").
'</div>';
600 print
'</fieldset>'.
"\n";
605print
'<script nonce="'.getNonce().
'" type="text/javascript">
606jQuery(document).ready(function() {
607 $("#submitcrop").click(function(e) {
608 console.log("We click on submitcrop");
609 var idClicked = e.target.id;
610 if (parseInt(jQuery(\'#w\').val())) return true;
611 alert(\''.
dol_escape_js($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Dimension"))).
'\');
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
Class to manage members of a foundation.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
Class to manage ECM files.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class of the module paid holiday.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage projects.
Class to manage proposals.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $src_y=0, $filetowrite='', $newquality=0)
Resize or crop an image file (Supported extensions are gif, jpg, png, bmp and webp)
dol_getImageSize($file, $url=false)
Return size of image file on disk (Supported extensions are gif, jpg, png, bmp and webp)
Class to generate the form for creating a new ticket.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.