diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 060f1d387c7f84aabd57ca2f60604a8865ed808f..aab33fa56d280e46004200f82ac6635383c615dc 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -857,9 +857,16 @@ class FormFile { if (image_format_supported($file['name']) > 0) { - // TODO Add link from photo page here - - + $permtoedit=0; + if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) $permtoedit=1; + if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoedit=1; + if (empty($conf->global->MAIN_UPLOAD_DOC)) $permtoedit=0; + + if ($permtoedit) + { + // Link to resize + print '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$object->id.'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'</a> '; + } } } if ($permtodelete) diff --git a/htdocs/core/js/lib_photosresize.js b/htdocs/core/js/lib_photosresize.js index 6847de0bd54a081dafb1da8fd42e5d93d3128dae..3463b82931fcd4873fcf574634c62deccc5e8f00 100644 --- a/htdocs/core/js/lib_photosresize.js +++ b/htdocs/core/js/lib_photosresize.js @@ -40,11 +40,3 @@ function updateCoords(c) jQuery('#w').val(Math.ceil(c.w * ratio)); jQuery('#h').val(Math.ceil(c.h * ratio)); }; - -/* checkCoords */ -function checkCoords() -{ - if (parseInt(jQuery('#w').val())) return true; - alert('Please select a crop region then press submit.'); - return false; -}; diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index e6a84657d874932c45fcf8e328d4830ce65a90c2..ff2e9c14dbe3a3428387c3d7606f29cc8a32f31c 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -114,10 +114,12 @@ function product_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'product'); + /* Merged into the Join files tab $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$object->id; $head[$h][1] = $langs->trans("Photos"); $head[$h][2] = 'photos'; $h++; + */ // Attachments require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 80f849a04943585234c9a27d62b1198c8136501e..9a3f69ac6c153cf508ada543cffdc7ff5bf2557e 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2010-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2009 Meos * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com> * @@ -46,6 +46,8 @@ $id=GETPOST('id','int'); $action=GETPOST('action','alpha'); $modulepart=GETPOST('modulepart','alpha')?GETPOST('modulepart','alpha'):'produit|service'; $original_file = isset($_REQUEST["file"])?urldecode($_REQUEST["file"]):''; +$backtourl=GETPOST('backtourl'); +$cancel=GETPOST("cancel"); // Security check if (empty($modulepart)) accessforbidden('Bad value for modulepart'); @@ -78,6 +80,20 @@ if ($id > 0) * Actions */ +if ($cancel) +{ + if ($backtourl) + { + header("Location: ".$backtourl); + exit; + } + else + { + header("Location: ".DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"])); + exit; + } +} + if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != "")) { $fullpath=$dir."/".$original_file; @@ -85,13 +101,24 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS if ($result == $fullpath) { - header("Location: ".DOL_URL_ROOT."/product/photos.php?id=".$id.'&action=addthumb&file='.urldecode($_POST["file"])); - exit; + $object->add_thumb($fullpath); + + if ($backtourl) + { + header("Location: ".$backtourl); + exit; + } + else + { + header("Location: ".DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"])); + exit; + } } else { - $mesg=$result; + setEventMessage($result, 'errors'); $_GET['file']=$_POST["file"]; + $action=''; } } @@ -103,13 +130,24 @@ if ($action == 'confirm_crop') if ($result == $fullpath) { - header("Location: ".DOL_URL_ROOT."/product/photos.php?id=".$id.'&action=addthumb&file='.urldecode($_POST["file"])); - exit; + $object->add_thumb($fullpath); + + if ($backtourl) + { + header("Location: ".$backtourl); + exit; + } + else + { + header("Location: ".DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"])); + exit; + } } else { - $mesg=$result; + setEventMessage($result, 'errors'); $_GET['file']=$_POST["file"]; + $action=''; } } @@ -123,8 +161,6 @@ llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('/includes/jquery/p print_fiche_titre($langs->trans("ImageEditor")); -if ($mesg) print '<div class="error">'.$mesg.'</div>'; - $infoarray=dol_getImageSize($dir."/".urldecode($_GET["file"])); $height=$infoarray['height']; $width=$infoarray['width']; @@ -133,6 +169,11 @@ print $langs->trans("Width").': <strong>'.$width.'</strong> x '.$langs->trans("H print '<br>'."\n"; + +/* + * Resize image + */ + print '<!-- Form to resize -->'."\n"; print '<form name="redim_file" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST">'; @@ -145,11 +186,15 @@ print '<input type="hidden" name="file" value="'.$_GET['file'].'" />'; print '<input type="hidden" name="action" value="confirm_resize" />'; print '<input type="hidden" name="product" value="'.$id.'" />'; print '<input type="hidden" name="id" value="'.$id.'" />'; -print '<br><input class="button" name="sendit" value="'.dol_escape_htmltag($langs->trans("Resize")).'" type="submit" />'; +print '<br>'; +print '<input class="button" id="submitresize" name="sendit" value="'.dol_escape_htmltag($langs->trans("Resize")).'" type="submit" />'; +print ' '; +print '<input type="submit" id="cancelresize" name="cancel" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" />'; print '</fieldset>'."\n"; print '</form>'; print '<br>'."\n"; + /* * Crop image */ @@ -168,7 +213,7 @@ if (! empty($conf->use_javascript_ajax)) $refsizeforcrop='screenwidth'; $ratioforcrop=2; } - + print '<!-- Form to crop -->'."\n"; print '<fieldset id="redim_file">'; print '<legend>'.$langs->trans("Recenter").'</legend>'; @@ -178,7 +223,7 @@ if (! empty($conf->use_javascript_ajax)) print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$object->entity.'&file='.$original_file.'" alt="" id="cropbox" width="'.$widthforcrop.'px"/>'; print '</div>'; print '</div><br>'; - print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post" onsubmit="return checkCoords();"> + print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post"> <div class="jc_coords"> '.$langs->trans("NewSizeAfterCropping").': <label>X1 <input type="text" size="4" id="x" name="x" /></label> @@ -188,19 +233,33 @@ if (! empty($conf->use_javascript_ajax)) <label>W <input type="text" size="4" id="w" name="w" /></label> <label>H <input type="text" size="4" id="h" name="h" /></label> </div> - + <input type="hidden" id="file" name="file" value="'.urlencode($original_file).'" /> <input type="hidden" id="action" name="action" value="confirm_crop" /> <input type="hidden" id="product" name="product" value="'.$id.'" /> <input type="hidden" id="refsizeforcrop" name="refsizeforcrop" value="'.$refsizeforcrop.'" /> <input type="hidden" id="ratioforcrop" name="ratioforcrop" value="'.$ratioforcrop.'" /> <input type="hidden" name="id" value="'.$id.'" /> - <br><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Recenter")).'" /> + <br> + <input type="submit" id="submitcrop" name="submitcrop" class="button" value="'.dol_escape_htmltag($langs->trans("Recenter")).'" /> + + <input type="submit" id="cancelcrop" name="cancel" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" /> </form>'."\n"; print '</fieldset>'."\n"; print '<br>'; } +/* Check that mandatory fields are filled */ +print '<script type="text/javascript" language="javascript"> +jQuery(document).ready(function() { + $("#submitcrop").click(function(e) { + var idClicked = e.target.id; + if (parseInt(jQuery(\'#w\').val())) return true; + alert(\''.dol_escape_js($langs->trans("ErrorFieldRequired", $langs->trans("Dimension"))).'\'); + return false; + }); +}); +</script>'; llxFooter(); $db->close(); diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php deleted file mode 100644 index f1fd687890d84056a7a3af11cea4ff4ca5a576a3..0000000000000000000000000000000000000000 --- a/htdocs/product/photos.php +++ /dev/null @@ -1,215 +0,0 @@ -<?php -/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> - * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -/** - * \file htdocs/product/photos.php - * \ingroup product - * \brief Onglet photos de la fiche produit - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - -$langs->load("products"); -$langs->load("bills"); - -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); - -// Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); - -$mesg = ''; - -$object = new Product($db); -if ($id > 0 || ! empty($ref)) -{ - $result = $object->fetch($id, $ref); - $dir = (! empty($conf->product->multidir_output[$object->entity])?$conf->product->multidir_output[$object->entity]:$conf->service->multidir_output[$object->entity]); -} - - -/* - * Actions - */ - -if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - if ($object->id) - { - if (image_format_supported($_FILES['userfile']['name']) >= 1) - { - $result = $object->add_photo($dir, $_FILES['userfile']); - if ($result > 0) setEventMessage($langs->trans("FileUploaded")); - else setEventMessage($langs->trans("FileNotUploaded"), 'errors'); - } - else - { - $langs->load("errors"); - setEventMessage($langs->trans("ErrorBadImageFormat"), 'errors'); - } - } -} - -if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer)) -{ - $object->delete_photo($dir."/".$_GET["file"]); -} - -if ($action == 'addthumb' && $_GET["file"]) -{ - $object->add_thumb($dir."/".$_GET["file"]); -} - - -/* - * View - */ - -$form = new Form($db); - -if ($object->id) -{ - llxHeader("","",$langs->trans("CardProduct".$object->type)); - - /* - * En mode visu - */ - $head=product_prepare_head($object); - $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); - dol_fiche_head($head, 'photos', $titre, 0, $picto); - - /* - * Confirmation de la suppression de photo - */ - if ($action == 'delete') - { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1); - - } - - print($mesg); - - print '<table class="border" width="100%">'; - - // Reference - print '<tr>'; - print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">'; - print $form->showrefnav($object,'ref','',1,'ref'); - print '</td>'; - print '</tr>'; - - // Libelle - print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$object->label.'</td>'; - print '</tr>'; - - // Status (to sell) - print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td>'; - print $object->getLibStatut(2,0); - print '</td></tr>'; - - // Status (to buy) - print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td>'; - print $object->getLibStatut(2,1); - print '</td></tr>'; - - print "</table>\n"; - - print "</div>\n"; - - - $permtoedit=0; - if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) $permtoedit=1; - if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoedit=1; - if (empty($conf->global->MAIN_UPLOAD_DOC)) $permtoedit=0; - - /* ************************************************************************** */ - /* */ - /* Barre d'action */ - /* */ - /* ************************************************************************** */ -/* - print "\n<div class=\"tabsAction\">\n"; - - if ($action != 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer)) - { - if (! empty($conf->global->MAIN_UPLOAD_DOC)) - { - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=ajout_photo&id='.$object->id.'">'; - print $langs->trans("AddPhoto").'</a>'; - } - else - { - print '<a class="butActionRefused" href="#">e'; - print $langs->trans("AddPhoto").'</a>'; - } - } - - print "\n</div>\n"; -*/ - /* - * Add a photo - */ - if ($permtoedit) - { - // Show upload form - $formfile=new FormFile($db); - $formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("AddPhoto"), 1, 0, $permtoedit, 50, $object, '', false, '', 0); // ajax=false for the moment. true may not work. - } - //else print $langs->trans("NoPermissionToAddOrEditPhoto").'<br><br>'; // TODO Add this - - // Affiche photos - if ($action != 'ajout_photo') - { - $nbphoto=0; - $nbbyrow=5; - - $maxWidth = 160; - $maxHeight = 120; - - print $object->show_photos($dir,1,1000,$nbbyrow,1,($permtoedit?1:0)); - - if ($object->nbphoto < 1) - { - print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; - print '<tr align=center valign=middle border=1><td class="photo">'; - print "<br>".$langs->trans("NoPhotoYet")."<br><br>"; - print '</td></tr>'; - print '</table>'; - } - } -} -else -{ - print $langs->trans("ErrorUnknown"); -} - - -llxFooter(); -$db->close(); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 94a5b0f9dd13acf2069b4a8285f73f5fd17c5e86..85153272e400c5ce8d87ef700c9d3b2b1bfa513a 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2043,6 +2043,16 @@ div.pagination li.pagination span { line-height: 1.42857143; color: #000; text-decoration: none; + + border-color: #ccc; + + background-color: #f5f5f5; + background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)); + background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); + background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); + background-image: linear-gradient(to bottom, #ffffff, #e6e6e6); + background-repeat: repeat-x; } div.pagination li.pagination span.inactive { cursor: default; @@ -2086,7 +2096,15 @@ div.pagination li a:focus, div.pagination li span:focus { color: #000; background-color: #eee; - border-color: #ddd; + border-color: #ccc; + + background-image: -moz-linear-gradient(top, #eee, #ddd); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#eee), to(#ddd)); + background-image: -webkit-linear-gradient(top, #eee, #ddd); + background-image: -o-linear-gradient(top, #eee, #ddd); + background-image: linear-gradient(to bottom, #eee, #ddd); + background-repeat: repeat-x; + } div.pagination li .active a, div.pagination li .active span,