Add php files
This commit is contained in:
34
modules/EcmPriceBooks2/AddToPriceBook.php
Executable file
34
modules/EcmPriceBooks2/AddToPriceBook.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?
|
||||
$result = $GLOBALS['db']->query("select name,id from ecmproducts where deleted='0'");
|
||||
$ile=$result->num_rows;
|
||||
if(!$_REQUEST['pricebook_id'])$_REQUEST['pricebook_id']=$_SESSION['add_to_pricebook_id'];
|
||||
$arr=array();
|
||||
for($i=0;$i<$ile;$i++)
|
||||
{
|
||||
if($_REQUEST['check'][$i])$arr[]=$i;
|
||||
}
|
||||
|
||||
foreach($arr as $i)
|
||||
{
|
||||
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select remarks from ecmproduct_language where language='PL' and ecmproduct_id='".$_REQUEST['check'][$i]."'"));
|
||||
$remarks_pl=$rr['remarks'];
|
||||
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select remarks from ecmproduct_language where language='EN' and ecmproduct_id='".$_REQUEST['check'][$i]."'"));
|
||||
$remarks_en=$rr['remarks'];
|
||||
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select remarks from ecmproduct_language where language='DE' and ecmproduct_id='".$_REQUEST['check'][$i]."'"));
|
||||
$remarks_de=$rr['remarks'];
|
||||
|
||||
$w=$GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_REQUEST['pricebook_id']."' and deleted='0' and ecmproduct_id='".$_REQUEST['check'][$i]."'");
|
||||
$price=floatval(str_replace(",",".",$_REQUEST['list_price_'.$_REQUEST['check'][$i]]));
|
||||
if(mysql_num_rows($w)==0)
|
||||
{
|
||||
$GLOBALS['db']->query("insert into ecmpricebooks_ecmproducts(id,ecmpricebook_id,ecmproduct_id,deleted,price,remarks_pl,remarks_en,remarks_de,created_by,date_entered,date_modified,modified_user_id) values('".create_guid()."','".$_REQUEST['pricebook_id']."','".$_REQUEST['check'][$i]."','0','".$price."','".$remarks_pl."','".$remarks_en."','".$remarks_de."','".$_SESSION['authenticated_user_id']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','".$_SESSION['authenticated_user_id']."')");
|
||||
}
|
||||
else
|
||||
{
|
||||
$z="update ecmpricebooks_ecmproducts set price='".$price."' where ecmpricebook_id='".$_REQUEST['pricebook_id']."' and ecmproduct_id='".$_REQUEST['check'][$i]."'";
|
||||
$GLOBALS['db']->query($z);
|
||||
}
|
||||
}
|
||||
//print mysql_error();
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_REQUEST['pricebook_id']."&tab=items");
|
||||
?>
|
||||
371
modules/EcmPriceBooks2/CreatePDF.php
Executable file
371
modules/EcmPriceBooks2/CreatePDF.php
Executable file
@@ -0,0 +1,371 @@
|
||||
<?php
|
||||
//error_reporting(0);
|
||||
set_time_limit(99999999);
|
||||
define('RELATIVE_PATH','include/html2fpdf/');
|
||||
define('FPDF_FONTPATH','include/html2fpdf/font/');
|
||||
require_once("include/html2fpdf/html2fpdf.php");
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
|
||||
$_SESSION['pricebook_images']=$_REQUEST['images'];
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id,description,ecmlanguage,currency_value from ecmpricebooks where id='".$_SESSION['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$description=$r['description'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
$lang=$r['ecmlanguage'];
|
||||
$er_value=$r['currency_value'];
|
||||
if(!$er_value){
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
}
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
$lc=0;
|
||||
foreach($t as $tt)
|
||||
{
|
||||
if($tt!="")$lc++;
|
||||
}
|
||||
if($lc>3)
|
||||
{
|
||||
$width=1100;
|
||||
$widthl=1020;
|
||||
$or="L";
|
||||
$title_width=$width-500;
|
||||
if($_REQUEST['images']=="true" || (!$_REQUEST['images'] && $_SESSION['pricebook_images_pdf']))
|
||||
{
|
||||
$l=5;
|
||||
$height=100;
|
||||
$product_name_width=400;
|
||||
if ($lc>=4) $product_name_width = 300;
|
||||
}
|
||||
else
|
||||
{
|
||||
$l=8;
|
||||
$height=50;
|
||||
$product_name_width=500;
|
||||
}
|
||||
}
|
||||
elseif($lc==0){
|
||||
$width=720;
|
||||
$widthl=670;
|
||||
$or="P";
|
||||
$title_width=$width-500;
|
||||
if($_REQUEST['images']=="true" || (!$_REQUEST['images'] && $_SESSION['pricebook_images_pdf']))
|
||||
{
|
||||
$l=8;
|
||||
$height=100;
|
||||
$product_name_width=620;
|
||||
}
|
||||
else
|
||||
{
|
||||
$l=16;
|
||||
$height=50;
|
||||
$product_name_width=720;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$width=720;
|
||||
$widthl=670;
|
||||
$or="P";
|
||||
$title_width=$width-500;
|
||||
if($_REQUEST['images']=="true" || (!$_REQUEST['images'] && $_SESSION['pricebook_images_pdf']))
|
||||
{
|
||||
$l=8;
|
||||
$height=100;
|
||||
$product_name_width=200;
|
||||
}
|
||||
else
|
||||
{
|
||||
$l=16;
|
||||
$height=50;
|
||||
$product_name_width=300;
|
||||
}
|
||||
}
|
||||
//if(in_array($c,"name"))@$col_width=($width-$product_name_width)/($lc-1);
|
||||
//else
|
||||
$isname=false;
|
||||
foreach($c as $ccc){
|
||||
if($ccc=="name"){
|
||||
$isname=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($isname){
|
||||
if($_REQUEST['images']=="true")@$col_width=($width-100-$product_name_width)/($lc-1);
|
||||
else @$col_width=($width-$product_name_width)/($lc-1);
|
||||
}
|
||||
else{
|
||||
if($_REQUEST['images']=="true")@$col_width=($width-100)/$lc;
|
||||
else @$col_width=($width)/$lc;
|
||||
}
|
||||
|
||||
$pdf = new HTML2FPDF($or);
|
||||
$pdf->lMargin = 3;
|
||||
$pdf->rMargin = 0;
|
||||
$pdf->tMargin = 0;
|
||||
$pdf->bMargin = 0;
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
//print $where;
|
||||
$z="select
|
||||
ecmpricebooks_ecmproducts.price as price,
|
||||
ecmpricebooks_ecmproducts.recipient_code as recipient_code,
|
||||
ecmpricebooks_ecmproducts.id as idp,
|
||||
ecmpricebooks_ecmproducts.remarks_pl as remarks_pl,
|
||||
ecmpricebooks_ecmproducts.remarks_en as remarks_en,
|
||||
ecmpricebooks_ecmproducts.remarks_de as remarks_de,
|
||||
|
||||
|
||||
ecmproducts.*,
|
||||
if(ecmpricebooks_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmpricebooks_ecmproducts.price)),0) as margin_rate,
|
||||
|
||||
ecmproduct_language_pl_view.ean as ean_pl,
|
||||
ecmproduct_language_pl_view.short_description as short_description_pl,
|
||||
ecmproduct_language_pl_view.long_description as long_description_pl,
|
||||
ecmproduct_language_pl_view.remarks as default_remarks_pl,
|
||||
|
||||
ecmproduct_language_en_view.ean as ean_en,
|
||||
ecmproduct_language_en_view.short_description as short_description_en,
|
||||
ecmproduct_language_en_view.long_description as long_description_en,
|
||||
ecmproduct_language_en_view.remarks as default_remarks_en,
|
||||
|
||||
ecmproduct_language_de_view.ean as ean_de,
|
||||
ecmproduct_language_de_view.short_description as short_description_de,
|
||||
ecmproduct_language_de_view.long_description as long_description_de,
|
||||
ecmproduct_language_de_view.remarks as default_remarks_de
|
||||
|
||||
from ecmpricebooks_ecmproducts
|
||||
|
||||
left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
where ".$where." ecmpricebooks_ecmproducts.ecmpricebook_id='".$_SESSION['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'";
|
||||
//echo $z; return;
|
||||
$z.=" order by ecmpricebooks_ecmproducts.position";
|
||||
//print $z; die();
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
//print mysql_error();
|
||||
$j=0;
|
||||
$k=0;
|
||||
$st=0;
|
||||
$ile=1 + ceil(($result->num_rows-$l)/($l+1));
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result))
|
||||
{
|
||||
$stop[$row['count']]=false;
|
||||
$stop[$row['code']]=false;
|
||||
$sale30="";
|
||||
$qty30="";
|
||||
$sale90="";
|
||||
$qty90="";
|
||||
$sale180="";
|
||||
$qty180="";
|
||||
if($j==0)
|
||||
{
|
||||
if ($st==0) {
|
||||
|
||||
$html.='<table border="0" width="'.$width.'"><tr height="140" width="'.$width.'">';
|
||||
$html.='<td style="padding-right:0px" height="140" align="center" width="900"><img src="modules/EcmPriceBooks/card_images/topper.jpg" border="0" width="800" height="100"></td>';
|
||||
$html.='<td height="140" align="center" width="150"><font color="#808080">'.iconv("UTF-8","ISO-8859-2",$description).'</font></td>';
|
||||
$html.='</tr></table>';
|
||||
} else {
|
||||
$html.='<table border="0" width="'.$width.'"><tr height="40" width="'.$width.'">';
|
||||
$html.='<td style="padding-right:0px" height="40" align="center" width="900"><img src="modules/EcmPriceBooks/card_images/cennik.jpg" border="0" width="30" height="30"></td>';
|
||||
$html.='<td height="40" align="center" width="150"></td>';
|
||||
$html.='</tr></table>';
|
||||
}
|
||||
if ($st==1) $l++;
|
||||
$html.='<table border=1><tr align="center" height="30" width="'.$width.'">';
|
||||
if($_REQUEST['images']=="true" || (!$_REQUEST['images'] && $_SESSION['pricebook_images_pdf']))$html.='<td bgcolor="#008CD1" height="30" width="80"> </td>';
|
||||
//$html.='<td bgcolor="#FF6600" align="center" height="30" width="'.$product_name_width.'"><font color="#ffffff">Product name</font></td>';
|
||||
|
||||
for($i=0;$i<count($t);$i++)
|
||||
{
|
||||
if($c[$i]=="name")$html.='<td bgcolor="#008CD1" align="center" height="30" width="'.$product_name_width.'"><font color="#ffffff">'.$t[$i].'</font></td>';
|
||||
elseif($t[$i])$html.='<td bgcolor="#008CD1" align="center" height="30" width="'.$col_width.'"><font color="#ffffff">'.iconv("UTF-8","ISO-8859-2",$t[$i]).'</font></td>';
|
||||
}
|
||||
$html.='</tr>';
|
||||
}
|
||||
|
||||
//if ($j % 2 == 1) $bg = 'bgcolor="#EBEDED"'; else $bg='';
|
||||
|
||||
$html.='<tr height="'.$height.'" width="'.$width.'">';
|
||||
if($_REQUEST['images']=="true")$html.='<td '.$bg.' height="'.$height.'" align="left" width="100">';
|
||||
if($_REQUEST['images']=="true" && (substr($row['product_picture'],-3,3)=="jpg" || substr($row['product_picture'],-3,3)=="png" || substr($row['product_picture'],-3,3)=="gif" || substr($row['product_picture'],-4,4)=="jpeg") && file_exists("modules/EcmProducts/upload/images/".$row['product_picture']) && $row['product_picture']){
|
||||
|
||||
$image_big='modules/EcmProducts/upload/images/'.$row['product_picture'];
|
||||
$image_thumb='modules/EcmProducts/upload/images/thumbs/'.$row['product_picture'];
|
||||
|
||||
if(!file_exists($image_thumb)){
|
||||
$imgo=@GetImageSize($image_big);
|
||||
resizeImage($image_big,100,100,$image_thumb,100);
|
||||
}
|
||||
/*
|
||||
$imgo=@GetImageSize($image_big);
|
||||
$is=90;
|
||||
if($imgo[0]>=$is){
|
||||
$widtho=$is;
|
||||
$heighto=$imgo[1]*$widtho/$imgo[0];
|
||||
if($heighto>$is){
|
||||
$heighto=$is;
|
||||
$widtho=$imgo[0]*$heighto/$imgo[1];
|
||||
}
|
||||
}
|
||||
else{
|
||||
$widtho=$imgo[0];
|
||||
$heighto=$imgo[1];
|
||||
}*/
|
||||
$widtho=90;
|
||||
$heighto=84;
|
||||
if(file_exists('modules/EcmProducts/upload/images/thumbs/'.$row['product_picture']))$html.='<img src="modules/EcmProducts/upload/images/thumbs/'.$row['product_picture'].'" width='.$widtho.' height='.$heighto.'>';
|
||||
else $html.="o";
|
||||
}
|
||||
if($_REQUEST['images']=="true")$html.='</td>';
|
||||
//$html.='<td valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['name']).'</td>';
|
||||
/*
|
||||
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select purchase_price from ecmproducts where id='".$row['id']."'"));
|
||||
$purchase_price=$rr['purchase_price'];
|
||||
@$margin=100-(100*$purchase_price/$row['price']);
|
||||
$margin=number_format($margin,2,",",".");*/
|
||||
|
||||
for($i=0;$i<count($t);$i++)
|
||||
{
|
||||
if($t[$i])
|
||||
{
|
||||
if(($c[$i]=="sale_qty30" || $c[$i]=="sale_qty90" || $c[$i]=="sale_qty180" || $c[$i]=="sale_avg_price30" || $c[$i]=="sale_avg_price90" || $c[$i]=="sale_avg_price180") && $stop[$row['code']]==false){
|
||||
$w=$GLOBALS['db']->query("select ecmproducts_fk_list.price as price,ecmproducts_fk_list.quantity as quantity,ecmproducts_fk_list.date as date from ecmproducts_fk_list where ecmproducts_fk_list.code like '".$row['code']."'");
|
||||
//echo mysql_error();die();
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$date=date("Y-m");
|
||||
$m=(int)date("m");
|
||||
$date1=date("Y-m",mktime(0,0,0,($m-1),1,date("Y")));
|
||||
$date2=date("Y-m",mktime(0,0,0,($m-2),1,date("Y")));
|
||||
$date3=date("Y-m",mktime(0,0,0,($m-3),1,date("Y")));
|
||||
$date4=date("Y-m",mktime(0,0,0,($m-4),1,date("Y")));
|
||||
$date5=date("Y-m",mktime(0,0,0,($m-5),1,date("Y")));
|
||||
$date6=date("Y-m",mktime(0,0,0,($m-6),1,date("Y")));
|
||||
|
||||
$d=explode("-",$r['date']);
|
||||
|
||||
$dd=$d[0]."-".$d[1];
|
||||
|
||||
if($dd==$date || $dd==$date1){
|
||||
$sale30+=$r['price']*$r['quantity'];
|
||||
$qty30+=$r['quantity'];
|
||||
$aq30[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date || $dd==$date1 || $dd==$date2 || $dd==$date3){
|
||||
$sale90+=$r['price']*$r['quantity'];
|
||||
$qty90+=$r['quantity'];
|
||||
$aq390[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date || $dd==$date1 || $dd==$date2 || $dd==$date3 || $dd==$date4 || $dd==$date5 || $dd==$date6){
|
||||
$sale180+=$r['price']*$r['quantity'];
|
||||
$qty180+=$r['quantity'];
|
||||
$aq180[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
}
|
||||
if($qty>0)$sq=round($sale/$qty,2);
|
||||
if($qty30>0)$sq30=round($sale30/$qty30,2);
|
||||
else $sq30="";
|
||||
if($qty90>0)$sq90=round($sale90/$qty90,2);
|
||||
else $sq90="";
|
||||
if($qty180>0)$sq180=round($sale180/$qty180,2);
|
||||
else $sq180="";
|
||||
$stop[$row['code']]=true;
|
||||
}
|
||||
|
||||
//if ($j % 2 == 0) $bg = 'bgcolor="#EBEDED"';
|
||||
|
||||
$tds='<td '.$bg.' valign="top" align="center" height="'.$height.'" width="'.$col_width.'">';
|
||||
$tde='</td>';
|
||||
|
||||
if($c[$i]=="ordered")$html.=$tds.number_format($row['ordered'],0,"","").$tde;
|
||||
elseif($c[$i]=="sale_qty30")$html.=$tds.number_format($qty30,0,"","").$tde;
|
||||
elseif($c[$i]=="sale_qty90")$html.=$tds.number_format($qty90,0,"","").$tde;
|
||||
elseif($c[$i]=="sale_qty180")$html.=$tds.number_format($qty180,0,"","").$tde;
|
||||
elseif($c[$i]=="sale_avg_price30")$html.=$tds.number_format($sq30,2,",",".").$tde;
|
||||
elseif($c[$i]=="sale_avg_price90")$html.=$tds.number_format($sq90,2,",",".").$tde;
|
||||
elseif($c[$i]=="sale_avg_price180")$html.=$tds.number_format($sq180,2,",",".").$tde;
|
||||
elseif($c[$i]=="ems_qty_in_stock")$html.=$tds.number_format($row['ems_qty_in_stock'],2,"","").$tde;
|
||||
elseif($c[$i]=="list_price")$html.=$tds.iconv("UTF-8","ISO-8859-2",addExchangeRateValue($row['price'],$c[$i],$er_value)).$tde;
|
||||
elseif($c[$i]=="margin_rate")$html.=$tds.number_format($row['margin_rate'],2,",",".").$tde;
|
||||
elseif($c[$i]=="name"){
|
||||
if($lang=="en_us"){
|
||||
$html.='<td '.$bg.' valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['short_description_en']).'</td>';
|
||||
}
|
||||
elseif($lang=="ge_ge"){
|
||||
$html.='<td '.$bg.' valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['short_description_de']).'</td>';
|
||||
}
|
||||
else $html.='<td '.$bg.' valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['name']).'</td>';
|
||||
}
|
||||
elseif($c[$i]=="product_category_name"){
|
||||
if($lang=="en_us"){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_en from ecmproductcategories where id='".$row['product_category_id']."'"));
|
||||
$html.=$tds.iconv("UTF-8","ISO-8859-2",$rrp['name_en']).$tde;
|
||||
}
|
||||
elseif($lang=="ge_ge"){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_de from ecmproductcategories where id='".$row['product_category_id']."'"));
|
||||
$html.=$tds.iconv("UTF-8","ISO-8859-2",$rrp['name_de']).$tde;
|
||||
}
|
||||
else $html.=$tds.iconv("UTF-8","ISO-8859-2",$row['product_category_name']).$tde;
|
||||
}
|
||||
else $html.=$tds.iconv("UTF-8","ISO-8859-2",addExchangeRateValue($row[$c[$i]],$c[$i],$er_value)).$tde;
|
||||
}
|
||||
}
|
||||
$html.='</tr>';
|
||||
$j++;
|
||||
$k++;
|
||||
|
||||
if($j==$l || $result->num_rows==$k)
|
||||
{
|
||||
$st++;
|
||||
$html.='</table>';
|
||||
$html.='<table border="0" width="'.$width.'"><tr height="30" width="'.$width.'">';
|
||||
$html.='<td height="30" align="left" width="'.$widthl.'"><img src="modules/EcmPriceBooks/card_images/footer.jpg" width="300" height="50"/></td>';
|
||||
$html.='<td height="30" align="right" width="80">'.$st.'/'.$ile.'</td>';
|
||||
$html.='</tr></table>';
|
||||
$ohtml=$html;
|
||||
$html='';
|
||||
$pdf->AddPage();
|
||||
$pdf->WriteHTML($ohtml);
|
||||
$j=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($_REQUEST['disposition']=="I")
|
||||
{
|
||||
$pdf->Output("Products.pdf", "I");
|
||||
}
|
||||
elseif($_REQUEST['disposition']=="D")
|
||||
{
|
||||
$pdf->Output("Products.pdf", "D");
|
||||
}
|
||||
else
|
||||
{
|
||||
$microtime=str_replace(".","",str_replace(" ","",microtime()));
|
||||
$pdf->Output("cache/upload/Products".$microtime.".pdf", "F");
|
||||
}
|
||||
?>
|
||||
73
modules/EcmPriceBooks2/CreateXLS.csv.php
Executable file
73
modules/EcmPriceBooks2/CreateXLS.csv.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<?
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
|
||||
if($_REQUEST['disposition']=="D")
|
||||
{
|
||||
header('Content-type: text/html; charset=windows-1250');
|
||||
header("Content-type: application/vnd.ms-excel");
|
||||
header("Content-Disposition: attachment; filename=\"Products.csv\"");
|
||||
header('Pragma: private');
|
||||
header('Cache-control: private, must-revalidate');
|
||||
}
|
||||
else
|
||||
{
|
||||
$microtime=str_replace(".","",str_replace(" ","",microtime()));
|
||||
}
|
||||
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
$z="select ecmpricebooks_ecmproducts.price as price,ecmpricebooks_ecmproducts.recipient_code as recipient_code,ecmpricebooks_ecmproducts.id as idp,ecmproducts.*,
|
||||
if(ecmpricebooks_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmpricebooks_ecmproducts.price)),0) as margin_rate from ecmpricebooks_ecmproducts left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id where ".$where."ecmpricebooks_ecmproducts.ecmpricebook_id='".$_SESSION['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'";
|
||||
if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order'];
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
print '"'.$t[$i].'",';
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
$j=1;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result)){
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if($c[$i]=="list_price")print '"'.addExchangeRateValue($row['price'],$c[$i],$er_value).'",';
|
||||
elseif($c[$i]=="margin_rate")print '"'.number_format($row['margin_rate'],2,",",".").'",';
|
||||
else print '"'.iconv("utf-8","cp1250",addExchangeRateValue($row[$c[$i]],$c[$i],$er_value)).'",';
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
$j++;
|
||||
}
|
||||
|
||||
?>
|
||||
128
modules/EcmPriceBooks2/CreateXLS.ok.php
Executable file
128
modules/EcmPriceBooks2/CreateXLS.ok.php
Executable file
@@ -0,0 +1,128 @@
|
||||
<?
|
||||
//require_once('include/write_excell/Worksheet.php');
|
||||
//require_once('include/write_excell/Workbook.php');
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
require_once('include/we/OLEwriter.php');
|
||||
require_once('include/we/BIFFwriter.php');
|
||||
require_once('include/we/Worksheet.php');
|
||||
require_once('include/we/Workbook.php');
|
||||
|
||||
if($_REQUEST['disposition']=="D")
|
||||
{
|
||||
header('Content-type: text/html; charset=windows-1250');
|
||||
header("Content-type: application/vnd.ms-excel");
|
||||
header("Content-Disposition: attachment; filename=\"Products.xls\"");
|
||||
header('Pragma: private');
|
||||
header('Cache-control: private, must-revalidate');
|
||||
$workbook = new Workbook("-");
|
||||
}
|
||||
else
|
||||
{
|
||||
$microtime=str_replace(".","",str_replace(" ","",microtime()));
|
||||
$workbook = new Workbook("cache/upload/Products".$microtime.".xls");
|
||||
}
|
||||
|
||||
$worksheet =& $workbook->add_worksheet('arkusz');
|
||||
$worksheet->set_column(0, 0, 45);
|
||||
$worksheet->set_column(1, 9, 15);
|
||||
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricebooks where id='".$_SESSION['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
//print $where;
|
||||
$z="select
|
||||
ecmpricebooks_ecmproducts.price as price,
|
||||
ecmpricebooks_ecmproducts.recipient_code as recipient_code,
|
||||
ecmpricebooks_ecmproducts.id as idp,
|
||||
ecmpricebooks_ecmproducts.remarks_pl as remarks_pl,
|
||||
ecmpricebooks_ecmproducts.remarks_en as remarks_en,
|
||||
ecmpricebooks_ecmproducts.remarks_de as remarks_de,
|
||||
|
||||
|
||||
ecmproducts.*,
|
||||
if(ecmpricebooks_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmpricebooks_ecmproducts.price)),0) as margin_rate,
|
||||
|
||||
ecmproduct_language_pl_view.ean as ean_pl,
|
||||
ecmproduct_language_pl_view.short_description as short_description_pl,
|
||||
ecmproduct_language_pl_view.long_description as long_description_pl,
|
||||
ecmproduct_language_pl_view.remarks as default_remarks_pl,
|
||||
|
||||
ecmproduct_language_en_view.ean as ean_en,
|
||||
ecmproduct_language_en_view.short_description as short_description_en,
|
||||
ecmproduct_language_en_view.long_description as long_description_en,
|
||||
ecmproduct_language_en_view.remarks as default_remarks_en,
|
||||
|
||||
ecmproduct_language_de_view.ean as ean_de,
|
||||
ecmproduct_language_de_view.short_description as short_description_de,
|
||||
ecmproduct_language_de_view.long_description as long_description_de,
|
||||
ecmproduct_language_de_view.remarks as default_remarks_de
|
||||
|
||||
from ecmpricebooks_ecmproducts
|
||||
|
||||
left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
where ".$where." ecmpricebooks_ecmproducts.ecmpricebook_id='".$_SESSION['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'";
|
||||
if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order'];
|
||||
|
||||
//print $z;
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
print mysql_error();
|
||||
$header =& $workbook->addformat();
|
||||
$header->set_bold();
|
||||
$header->set_size(12);
|
||||
$header->set_color('blue');
|
||||
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
$worksheet->write_string(0,$i,dy($t[$i]),$header);
|
||||
}
|
||||
}
|
||||
$j=1;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result)){
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if($c[$i]=="list_price")$worksheet->write($j,$i,dy(addExchangeRateValue($row['price'],$c[$i],$er_value)));
|
||||
elseif($c[$i]=="margin_rate")$worksheet->write($j,$i,dy(number_format($row['margin_rate'],2,",",".")));
|
||||
else $worksheet->write($j,$i,iconv("utf-8","windows-1250",addExchangeRateValue($row[$c[$i]],$c[$i],$er_value)));
|
||||
}
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
|
||||
|
||||
$workbook->close();
|
||||
|
||||
?>
|
||||
233
modules/EcmPriceBooks2/CreateXLS.php
Executable file
233
modules/EcmPriceBooks2/CreateXLS.php
Executable file
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
set_time_limit(99999999);
|
||||
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id,ecmlanguage,currency_value from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
$lang=$r['ecmlanguage'];
|
||||
$er_value=$r['currency_value'];
|
||||
if(!$er_value){
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
}
|
||||
set_include_path('include/PHPExcel/');
|
||||
include 'PHPExcel.php';
|
||||
include 'PHPExcel/Writer/Excel2007.php';
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
$objPHPExcel = new PHPExcel();
|
||||
//print "t";
|
||||
$objPHPExcel->getProperties()->setCreator("E5 CRM");
|
||||
$objPHPExcel->getProperties()->setLastModifiedBy("E5 CRM");
|
||||
$objPHPExcel->getProperties()->setTitle("Office 2007 PRICEBOOK");
|
||||
$objPHPExcel->getProperties()->setSubject("Office 2007 PRICEBOOK");
|
||||
$objPHPExcel->getProperties()->setDescription("PRICEBOOK");
|
||||
//print "t";
|
||||
|
||||
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
|
||||
array(
|
||||
'fill' => array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'color' => array('argb' => 'FFCCFFCC')
|
||||
),
|
||||
'borders' => array(
|
||||
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
|
||||
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
|
||||
)
|
||||
),
|
||||
"A1:Z1"
|
||||
);
|
||||
|
||||
//print "t";
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
//print $where;
|
||||
$z="select
|
||||
ecmpricebooks_ecmproducts.price as price,
|
||||
ecmpricebooks_ecmproducts.recipient_code as recipient_code,
|
||||
ecmpricebooks_ecmproducts.id as idp,
|
||||
ecmpricebooks_ecmproducts.remarks_pl as remarks_pl,
|
||||
ecmpricebooks_ecmproducts.remarks_en as remarks_en,
|
||||
ecmpricebooks_ecmproducts.remarks_de as remarks_de,
|
||||
|
||||
|
||||
ecmproducts.*,
|
||||
if(ecmpricebooks_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmpricebooks_ecmproducts.price)),0) as margin_rate,
|
||||
|
||||
ecmproduct_language_pl_view.ean as ean_pl,
|
||||
ecmproduct_language_pl_view.short_description as short_description_pl,
|
||||
ecmproduct_language_pl_view.long_description as long_description_pl,
|
||||
ecmproduct_language_pl_view.remarks as default_remarks_pl,
|
||||
|
||||
ecmproduct_language_en_view.ean as ean_en,
|
||||
ecmproduct_language_en_view.short_description as short_description_en,
|
||||
ecmproduct_language_en_view.long_description as long_description_en,
|
||||
ecmproduct_language_en_view.remarks as default_remarks_en,
|
||||
|
||||
ecmproduct_language_de_view.ean as ean_de,
|
||||
ecmproduct_language_de_view.short_description as short_description_de,
|
||||
ecmproduct_language_de_view.long_description as long_description_de,
|
||||
ecmproduct_language_de_view.remarks as default_remarks_de
|
||||
|
||||
from ecmpricebooks_ecmproducts
|
||||
|
||||
left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
where ".$where." ecmpricebooks_ecmproducts.ecmpricebook_id='".$_SESSION['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'";
|
||||
if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order'];
|
||||
|
||||
//print $z;
|
||||
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
$alf="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if($c[$i]=="name")$width="50";
|
||||
else $width="30";
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension($alf[$i])->setWidth($width);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].'1',$t[$i]);
|
||||
}
|
||||
}
|
||||
$j=2;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result)){
|
||||
$stop[$row['code']]=false;
|
||||
$stop[$row['code']]=false;
|
||||
$sale30="";
|
||||
$qty30="";
|
||||
$sale90="";
|
||||
$qty90="";
|
||||
$sale180="";
|
||||
$qty180="";
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if(($c[$i]=="sale_qty30" || $c[$i]=="sale_qty90" || $c[$i]=="sale_qty180" || $c[$i]=="sale_avg_price30" || $c[$i]=="sale_avg_price90" || $c[$i]=="sale_avg_price180") && $stop[$row['code']]==false){
|
||||
$w=$GLOBALS['db']->query("select ecmproducts_fk_list.price as price,ecmproducts_fk_list.quantity as quantity,ecmproducts_fk_list.date as date from ecmproducts_fk_list where ecmproducts_fk_list.code like '".$row['code']."'");
|
||||
//echo mysql_error();die();
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$date=date("Y-m");
|
||||
$m=(int)date("m");
|
||||
$date1=date("Y-m",mktime(0,0,0,($m-1),1,date("Y")));
|
||||
$date2=date("Y-m",mktime(0,0,0,($m-2),1,date("Y")));
|
||||
$date3=date("Y-m",mktime(0,0,0,($m-3),1,date("Y")));
|
||||
$date4=date("Y-m",mktime(0,0,0,($m-4),1,date("Y")));
|
||||
$date5=date("Y-m",mktime(0,0,0,($m-5),1,date("Y")));
|
||||
$date6=date("Y-m",mktime(0,0,0,($m-6),1,date("Y")));
|
||||
|
||||
$d=explode("-",$r['date']);
|
||||
|
||||
$dd=$d[0]."-".$d[1];
|
||||
|
||||
if($dd==$date || $dd==$date1){
|
||||
$sale30+=$r['price']*$r['quantity'];
|
||||
$qty30+=$r['quantity'];
|
||||
$aq30[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date || $dd==$date1 || $dd==$date2 || $dd==$date3){
|
||||
$sale90+=$r['price']*$r['quantity'];
|
||||
$qty90+=$r['quantity'];
|
||||
$aq390[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date || $dd==$date1 || $dd==$date2 || $dd==$date3 || $dd==$date4 || $dd==$date5 || $dd==$date6){
|
||||
$sale180+=$r['price']*$r['quantity'];
|
||||
$qty180+=$r['quantity'];
|
||||
$aq180[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
}
|
||||
if($qty>0)$sq=round($sale/$qty,2);
|
||||
if($qty30>0)$sq30=round($sale30/$qty30,2);
|
||||
else $sq30="";
|
||||
if($qty90>0)$sq90=round($sale90/$qty90,2);
|
||||
else $sq90="";
|
||||
if($qty180>0)$sq180=round($sale180/$qty180,2);
|
||||
else $sq180="";
|
||||
|
||||
$stop[$row['code']]=true;
|
||||
}
|
||||
|
||||
if($c[$i]=="ordered")$html.=$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['ordered']);
|
||||
elseif($c[$i]=="sale_qty30")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$qty30);
|
||||
elseif($c[$i]=="sale_qty90")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$qty90);
|
||||
elseif($c[$i]=="sale_qty180")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$qty180);
|
||||
elseif($c[$i]=="sale_avg_price30")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$sq30);
|
||||
elseif($c[$i]=="sale_avg_price90")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$sq90);
|
||||
elseif($c[$i]=="sale_avg_price180")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$sq180);
|
||||
elseif($c[$i]=="ems_qty_in_stock")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['ems_qty_in_stock']);
|
||||
elseif($c[$i]=="list_price")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,addExchangeRateValue($row['price'],$c[$i],$er_value,true));
|
||||
elseif($c[$i]=="margin_rate")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['margin_rate']);
|
||||
elseif($c[$i]=="name"){
|
||||
if($lang=="en_us"){
|
||||
//$html.='<td valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['short_description_en']).'</td>';
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['short_description_en']);
|
||||
}
|
||||
elseif($lang=="ge_ge"){
|
||||
//$html.='<td valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['short_description_en']).'</td>';
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['short_description_de']);
|
||||
}
|
||||
else {
|
||||
//$html.='<td valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['name']).'</td>';
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['name']);
|
||||
}
|
||||
}
|
||||
elseif($c[$i]=="product_category_name"){
|
||||
if($lang=="en_us"){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_en from ecmproductcategories where id='".$row['product_category_id']."'"));
|
||||
//$html.=$tds.iconv("UTF-8","ISO-8859-2",$rrp['name_en']).$tde;
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$rrp['name_en']);
|
||||
}
|
||||
elseif($lang=="ge_ge"){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_de from ecmproductcategories where id='".$row['product_category_id']."'"));
|
||||
//$html.=$tds.iconv("UTF-8","ISO-8859-2",$rrp['name_en']).$tde;
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$rrp['name_de']);
|
||||
}
|
||||
else {
|
||||
//$html.=$tds.iconv("UTF-8","ISO-8859-2",$row['product_category_name']).$tde;
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['product_category_name']);
|
||||
}
|
||||
}
|
||||
else $objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,addExchangeRateValue($row[$c[$i]],$c[$i],$er_value,true));
|
||||
}
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
//print "t";
|
||||
//$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
//print "t";
|
||||
$microtime=str_replace(".","",str_replace(" ","",microtime()));
|
||||
$name="cache/upload/Products".$microtime.".xlsx";
|
||||
$objWriter->save($name);
|
||||
//print "tr";
|
||||
chmod($name,0777);
|
||||
//print $name;
|
||||
if($_REQUEST['disposition']=="D")header("Location: ".$name);
|
||||
?>
|
||||
72
modules/EcmPriceBooks2/CreateXLS1.php
Executable file
72
modules/EcmPriceBooks2/CreateXLS1.php
Executable file
@@ -0,0 +1,72 @@
|
||||
<?
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
|
||||
header("Content-Type: application/vnd.ms-excel");
|
||||
header("Content-Disposition: attachment; filename=Products.xls");
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: 0");
|
||||
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
$z="select ecmpricebooks_ecmproducts.price as price,ecmpricebooks_ecmproducts.recipient_code as recipient_code,ecmpricebooks_ecmproducts.id as idp,ecmproducts.*,
|
||||
if(ecmpricebooks_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmpricebooks_ecmproducts.price)),0) as margin_rate from ecmpricebooks_ecmproducts left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id where ".$where."ecmpricebooks_ecmproducts.ecmpricebook_id='".$_COOKIE['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'";
|
||||
if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order'];
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
|
||||
$ca="abcdefghijklmnopqrstuvwxyz";
|
||||
$html='';
|
||||
$html.='<table border="1">';
|
||||
$html.='<tr>';
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
|
||||
$html.='<th><b>'.iconv("utf-8","cp1250",$t[$i]).'</b></th>';
|
||||
}
|
||||
}
|
||||
$html.='</tr>';
|
||||
$j=1;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result)){
|
||||
$html.='<tr>';
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if($c[$i]=="list_price")$html.='<td>'.iconv("utf-8","cp1250",addExchangeRateValue($row['price'],$c[$i],$er_value)).'</td>';
|
||||
elseif($c[$i]=="margin_rate")$html.='<td>'.number_format($row['margin_rate'],2,",",".").'</td>';
|
||||
else $html.='<td>'.iconv("utf-8","cp1250",addExchangeRateValue($row[$c[$i]],$c[$i],$er_value)).'</td>';
|
||||
}
|
||||
}
|
||||
$html.='</tr>';
|
||||
$j++;
|
||||
}
|
||||
$html.='</table>';
|
||||
echo $html;
|
||||
?>
|
||||
73
modules/EcmPriceBooks2/CreateXLS2.php
Executable file
73
modules/EcmPriceBooks2/CreateXLS2.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<?
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
require ("modules/EcmPriceBooks/excel.php");
|
||||
$workbook = "test.xls";
|
||||
$pathin = "/var/www/html/e5crm/vserver/e5crm.more7.com/www/e5test/modules/EcmPriceBooks/";
|
||||
$sheet = "test";
|
||||
$pathout = "/";
|
||||
|
||||
$E = new Excel;
|
||||
$E->XL($workbook,$pathin,$sheet);
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
$alf="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
$result = $GLOBALS['db']->query("select ecmpricebooks_ecmproducts.price as price,ecmpricebooks_ecmproducts.id as idp,ecmproducts.* from ecmpricebooks_ecmproducts left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id where ".$where."ecmpricebooks_ecmproducts.ecmpricebook_id='".$_COOKIE['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0' order by ".$_SESSION['pricebook_order_by']." ".$_SESSION['pricebook_sorder']);
|
||||
|
||||
$header =& $workbook->addformat();
|
||||
$header->set_bold();
|
||||
$header->set_size(12);
|
||||
$header->set_color('blue');
|
||||
|
||||
$worksheet->write_string(0,0,"Product name",$header);
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
//$worksheet->write_string(0,$i+1,dy($t[$i]),$header);
|
||||
$E->writerange("sheet1","A".$i+1,$t[$i]);
|
||||
}
|
||||
}
|
||||
$j=1;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result)){
|
||||
$worksheet->write($j,0,dy($row['name']));
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if($c[$i]=="list_price")$E->writerange("sheet1",$alf[$j].$i+1,addExchangeRateValue($row['price'],$c[$i],$er_value));
|
||||
else $E->writerange("sheet1",$alf[$j].$i+1,addExchangeRateValue($c[$i],$c[$i],$er_value));
|
||||
}
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
$E->saveas("newwkb",$pathout,"xls");
|
||||
$E->closexl();
|
||||
unset($E);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
global $current_user;
|
||||
|
||||
$dashletData['MyEcmPriceBooksDashlet']['searchFields'] = array(
|
||||
'date_entered' => array('default' => ''),
|
||||
'date_modified' => array('default' => ''),
|
||||
'assigned_user_id' => array('type' => 'assigned_user_name',
|
||||
'default' => $current_user->name)
|
||||
);
|
||||
|
||||
$dashletData['MyEcmPriceBooksDashlet']['columns'] = array(
|
||||
'name' => array(
|
||||
'width' => '40',
|
||||
'label' => 'LBL_LIST_NAME',
|
||||
'link' => true,
|
||||
'default' => true),
|
||||
'date_entered' => array(
|
||||
'width' => '15',
|
||||
'label' => 'LBL_DATE_ENTERED'),
|
||||
'date_modified' => array(
|
||||
'width' => '15',
|
||||
'label' => 'LBL_DATE_MODIFIED'),
|
||||
'created_by' => array(
|
||||
'width' => '8',
|
||||
'label' => 'LBL_CREATED'),
|
||||
'assigned_user_name' => array(
|
||||
'width' => '8',
|
||||
'label' => 'LBL_LIST_ASSIGNED_USER'),
|
||||
);
|
||||
?>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
global $app_strings;
|
||||
|
||||
$dashletMeta['MyEcmPriceBooksDashlet'] = array(
|
||||
'title' => translate('LBL_LIST_MY_ECMPRICEBOOKS', 'EcmPriceBooks'),
|
||||
'icon' => 'modules/EcmPriceBooks/images/EcmPriceBooks.gif',
|
||||
'description' => 'A customizable view into EcmPriceBooks',
|
||||
'category' => 'Module Views'
|
||||
);
|
||||
?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/Dashlets/DashletGeneric.php');
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once('modules/EcmPriceBooks/Dashlets/MyEcmPriceBooksDashlets/MyEcmPriceBooksDashlet.data.php');
|
||||
|
||||
class MyEcmPriceBooksDashlet extends DashletGeneric {
|
||||
function MyEcmPriceBooksDashlet($id, $def = null) {
|
||||
global $current_user, $app_strings, $dashletData;
|
||||
parent::DashletGeneric($id, $def);
|
||||
|
||||
$this->searchFields = $dashletData['MyEcmPriceBooksDashlet']['searchFields'];
|
||||
$this->columns = $dashletData['MyEcmPriceBooksDashlet']['columns'];
|
||||
|
||||
if(empty($def['title']))
|
||||
$this->title = translate('LBL_LIST_MY_ECMPRICEBOOKS', 'EcmPriceBooks');
|
||||
$this->seedBean = new EcmPriceBook();
|
||||
}
|
||||
|
||||
function displayOptions() {
|
||||
$this->processDisplayOptions();
|
||||
$this->configureSS->assign('searchFields', $this->currentSearchFields);
|
||||
return $this->configureSS->fetch($this->configureTpl);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
67
modules/EcmPriceBooks2/Delete.php
Executable file
67
modules/EcmPriceBooks2/Delete.php
Executable file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
|
||||
$focus = new EcmPriceBook();
|
||||
|
||||
// PERFORM THE DELETE IF GIVEN A RECORD TO DELETE
|
||||
if(!isset($_REQUEST['record']))
|
||||
sugar_die("A record number must be specified to delete the record.");
|
||||
$focus->retrieve($_REQUEST['record']);
|
||||
if(!$focus->ACLAccess('Delete')){
|
||||
ACLController::displayNoAccess(true);
|
||||
sugar_cleanup(true);
|
||||
}
|
||||
$focus->mark_deleted($_REQUEST['record']);
|
||||
|
||||
// NOW THAT THE DELETE HAS BEEN PERFORMED, RETURN TO GIVEN LOCATION
|
||||
header("Location: index.php?module=".$_REQUEST['return_module']."&action=".$_REQUEST['return_action']."&record=".$_REQUEST['return_id']);
|
||||
?>
|
||||
7
modules/EcmPriceBooks2/DeleteCustomView.php
Executable file
7
modules/EcmPriceBooks2/DeleteCustomView.php
Executable file
@@ -0,0 +1,7 @@
|
||||
<?
|
||||
$sugarEntry=true;
|
||||
global $db;
|
||||
$db->query("delete from ecmpricebooks_customview where id='".$_REQUEST['record']."'");
|
||||
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_COOKIE['pricebook_id']);
|
||||
?>
|
||||
33
modules/EcmPriceBooks2/DeleteFromPriceBook.php
Executable file
33
modules/EcmPriceBooks2/DeleteFromPriceBook.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?
|
||||
if($_REQUEST['action']!="DeleteFromPriceBook" || !$_REQUEST['but'])die();
|
||||
//echo $_REQUEST['return_id'];
|
||||
//print_r($_SESSION['pricebook_check']);
|
||||
/*
|
||||
$sugarEntry=true;
|
||||
global $db;
|
||||
$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set deleted='1' where ecmpricebook_id='".$_REQUEST['pricebook_id']."' and ecmproduct_id='".$_REQUEST['record']."'");
|
||||
$_REQUEST['customview_id']=$_COOKIE['customview_id'];
|
||||
include("modules/EcmPriceBooks/ListViewProductsAjax.php");*/
|
||||
$input=array();
|
||||
if(count($_SESSION['pricebook_check'][$_REQUEST['return_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_REQUEST['return_id']] as $key=>$value)
|
||||
{
|
||||
if($_SESSION['pricebook_check'][$_REQUEST['return_id']][$key]=="true")
|
||||
{
|
||||
//$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set date_modified='".date("Y-m-d H:i:s")."',modified_user_id='".$_SESSION['authenticated_user_id']."',deleted='1' where id='".$key."' and ecmpricebook_id='".$_REQUEST['return_id']."'");
|
||||
$input[]=$key;
|
||||
}
|
||||
}
|
||||
}
|
||||
//print mysql_error();
|
||||
if(count($input)>0){
|
||||
echo '<form action="index.php?module=EcmPriceBooks&action=deleteProducts" method="post"><input type="hidden" value="'.implode("|",$input).'" name="keys"><input type="hidden" value="'.$_REQUEST['return_id'].'" name="return_id">Following products will be deleted:<br>';
|
||||
foreach($input as $in){
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select p.name,p.code from ecmproducts as p inner join ecmpricebooks_ecmproducts as e on e.ecmproduct_id=p.id where e.id='".$in."'"));
|
||||
echo $r['coce']." ".$r['name']."<br>";
|
||||
}
|
||||
echo '<br><input type="submit" name="del" value="Confirm"></form>';
|
||||
}
|
||||
|
||||
?>
|
||||
12
modules/EcmPriceBooks2/DeleteFromPriceBook1.php
Executable file
12
modules/EcmPriceBooks2/DeleteFromPriceBook1.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value)
|
||||
{
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true")
|
||||
{
|
||||
$GLOBALS['db']->query("delete from ecmpricebooks_ecmproducts where id='".$key."'");
|
||||
}
|
||||
}
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_REQUEST['return_id']);
|
||||
?>
|
||||
270
modules/EcmPriceBooks2/DetailView.php
Executable file
270
modules/EcmPriceBooks2/DetailView.php
Executable file
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
include ("modules/EcmProducts/moduleMenu.php");
|
||||
|
||||
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
||||
die ( 'Not A Valid Entry Point' );
|
||||
$_SESSION ['pricebook_duplicate_id'] = $_REQUEST ['record'];
|
||||
require_once ('XTemplate/xtpl.php');
|
||||
require_once ('data/Tracker.php');
|
||||
require_once ('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once ('modules/EcmPriceBooks/Forms.php');
|
||||
require_once ('include/DetailView/DetailView.php');
|
||||
|
||||
global $mod_strings;
|
||||
global $app_strings;
|
||||
global $db;
|
||||
|
||||
$focus = new EcmPriceBook ();
|
||||
|
||||
$detailView = new DetailView ();
|
||||
$offset = 0;
|
||||
|
||||
// ONLY LOAD A RECORD IF A RECORD ID IS GIVEN;
|
||||
// A RECORD ID IS NOT GIVEN WHEN VIEWING IN LAYOUT EDITOR
|
||||
if (isset ( $_REQUEST ['offset'] ) or isset ( $_REQUEST ['record'] )) {
|
||||
$result = $detailView->processSugarBean ( "ECMPRICEBOOKS", $focus, $offset );
|
||||
if ($result == null) {
|
||||
sugar_die ( $app_strings ['ERROR_NO_RECORD'] );
|
||||
}
|
||||
$focus = $result;
|
||||
} else {
|
||||
header ( "Location: index.php?module={EcmPriceBooks}&action=index" );
|
||||
}
|
||||
|
||||
if (isset ( $_REQUEST ['isDuplicate'] ) && $_REQUEST ['isDuplicate'] == 'true') {
|
||||
$focus->id = "";
|
||||
}
|
||||
echo "\n<p>\n";
|
||||
echo get_module_title ( $mod_strings ['LBL_MODULE_ID'], $mod_strings ['LBL_MODULE_NAME'] . ": " . $focus->name, true );
|
||||
echo "\n</p>\n";
|
||||
global $theme;
|
||||
$theme_path = "themes/" . $theme . "/";
|
||||
$image_path = $theme_path . "images/";
|
||||
require_once ($theme_path . 'layout_utils.php');
|
||||
/*
|
||||
* if(!$_SESSION['pricebook_check'][$_REQUEST['pricebook_id']]['all']){ $result = $GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts"); $checkc=''; while($ro=$GLOBALS['db']->fetchByAssoc($result)){ $_SESSION['pricebook_check'][$_REQUEST['pricebook_id']][$ro['id']]="true"; } $_SESSION['pricebook_check'][$_REQUEST['pricebook_id']]['all']="true"; }
|
||||
*/
|
||||
// $_SESSION['pricebook_check'][$_REQUEST['record']]['all']="true";
|
||||
$GLOBALS ['log']->info ( "EcmPriceBooks detail view" );
|
||||
$focus->format_all_fields ();
|
||||
$xtpl = new XTemplate ( 'modules/EcmPriceBooks/DetailView.html' );
|
||||
$xtpl->assign ( "MOD", $mod_strings );
|
||||
$xtpl->assign ( "APP", $app_strings );
|
||||
$xtpl->assign ( "THEME", $theme );
|
||||
$xtpl->assign ( "GRIDLINE", $gridline );
|
||||
$xtpl->assign ( "IMAGE_PATH", $image_path );
|
||||
$xtpl->assign ( "PRINT_URL", "index.php?" . $GLOBALS ['request_string'] );
|
||||
$xtpl->assign ( "ID", $focus->id );
|
||||
$xtpl->assign ( "ASSIGNED_TO", $focus->assigned_user_name );
|
||||
$xtpl->assign ( "NAME", $focus->name );
|
||||
$xtpl->assign ( "DATE_ENTERED", $focus->date_entered );
|
||||
$xtpl->assign ( "DATE_MODIFIED", $focus->date_modified );
|
||||
include ("modules/EcmDocs/Pagination.php");
|
||||
$xtpl->assign ( "PAGINATION1", getPagination ( "ecmpricebooks", "EcmPriceBooks", $_REQUEST ['record'] ) );
|
||||
|
||||
if ($focus->active == '1')
|
||||
$xtpl->assign ( 'ACTIVE', "Active" );
|
||||
elseif ($focus->active == '2')
|
||||
$xtpl->assign ( 'ACTIVE', "Inactive" );
|
||||
if ($focus->archived == '1')
|
||||
$xtpl->assign ( 'ARCHIVED', "checked" );
|
||||
$xtpl->assign ( "DESCRIPTION", nl2br ( url2html ( $focus->description ) ) );
|
||||
$r = $db->fetchByAssoc ( $db->query ( "select name from ecmproductexchangerates where id='" . $focus->exchange_rate_id . "'" ) );
|
||||
$focus->exchange_rate_name = $r ['name'];
|
||||
|
||||
$desc = '';
|
||||
$desc .= '<input title="Product Card" class="button" onclick="if(document.getElementById(\'div_desc2\').style.display==\'none\')document.getElementById(\'div_desc2\').style.display=\'block\';else document.getElementById(\'div_desc2\').style.display=\'none\';" type="button" name="productcard" id="productcard" value="' . $mod_strings ['LBL_PRODUCT_CARD'] . '">';
|
||||
$desc .= '<div id="div_desc2" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
|
||||
$desc .= 'To image: <select name="new_image" id="new_image"><option value="1">Yes</option><option value="0" selected>No</option></select><br /><br />';
|
||||
$desc .= 'Show price: <select name="new_show_price" id="new_show_price"><option value="1">Yes</option><option value="0" selected>No</option></select><br /><br />';
|
||||
$desc .= 'Price: <select name="new_price" id="new_price"><option value="srp_price">SRP Price</option></select><br /><br />';
|
||||
$desc .= 'Language: <select name="new_language" id="new_language"><option value="pl">pl</option><option value="en">en</option></select><br /><br />';
|
||||
$desc .= 'EAN: <select name="new_ean" id="new_ean"><option value="1">1</option><option value="2">2</option></select><br /><br />';
|
||||
$desc.='<input type="button" class="button" name="generate" id="generate" value="Generate" onclick="window.open(\'index.php?module=EcmProducts&action=generateProductCardsFromPricebook&record='.$_REQUEST['record'].'&to_pdf=1&price=\'+document.getElementById(\'new_price\').value+\'&create_img=\'+document.getElementById(\'new_image\').value+\'&show_price=\'+document.getElementById(\'new_show_price\').value+\'&language=\'+document.getElementById(\'new_language\').value+\'&ean=\'+document.getElementById(\'new_ean\').value);"></div>';
|
||||
|
||||
|
||||
$xtpl->assign ( "CATALOGUE", $desc );
|
||||
|
||||
$xtpl->assign ( "EXCHANGE_RATE_NAME", $focus->exchange_rate_name );
|
||||
$xtpl->assign ( "EXCHANGE_RATE_ID", $focus->exchange_rate_id );
|
||||
$xtpl->assign ( "ACCOUNT_NAME", $focus->account_name );
|
||||
$xtpl->assign ( "ACCOUNT_ID", $focus->account_id );
|
||||
$xtpl->assign ( "LEAD_NAME", $focus->lead_name );
|
||||
$xtpl->assign ( "LEAD_ID", $focus->lead_id );
|
||||
if ($focus->name == "leobitepl" || $focus->name == "www.e5" || $focus->name == "getmir") {
|
||||
// $xtpl->assign("NAME_style", 'style="display:none;"');
|
||||
if ($focus->name == "leobitepl") {
|
||||
$addrl = "leobite.pl";
|
||||
$shop = "leobite";
|
||||
} elseif ($focus->name == "getmir") {
|
||||
$addrl = "getmir.com";
|
||||
$shop = "Getmir shop";
|
||||
} else {
|
||||
$addrl = "e5.pl";
|
||||
$shop = "e5 shop PL";
|
||||
}
|
||||
$xtpl->assign ( "LEOBITE", '<input title="Update prices on leobite"
|
||||
class="button"
|
||||
onclick="window.open(\'http://www.' . $addrl . '/administrator/components/com_virtuemart/more7_refreshStock.php?m7_debug=0&m7_test=1\');"
|
||||
type="button"
|
||||
name="upol"
|
||||
value=" Update prices on ' . $shop . ' ">' );
|
||||
}
|
||||
if ($focus->name == "www.e5") {
|
||||
$addrl = "shop-en.e5.pl";
|
||||
$shop = "e5 shop EN";
|
||||
$xtpl->assign ( "LEOBITEEN", '<input title="Update prices on leobite"
|
||||
class="button"
|
||||
onclick="window.open(\'http://' . $addrl . '/administrator/components/com_virtuemart/more7_refreshStock.php?m7_debug=0&m7_test=1\');"
|
||||
type="button"
|
||||
name="upol"
|
||||
value=" Update prices on ' . $shop . ' ">' );
|
||||
}
|
||||
|
||||
$xtpl->assign ( "SHOWPDF", '<input title="Pokaż PDF"
|
||||
class="button"
|
||||
onclick="location.href=\'index.php?module=EcmPriceBooks&action=CreatePDF&record=' . $focus->id . '&to_pdf=1&disposition=D&images=\'+document.getElementById(\'images\').checked;"
|
||||
type="button"
|
||||
name="showpdf"
|
||||
value="Pokaż PDF">' );
|
||||
$xtpl->assign ( "SORT_ORDER", '<input title="Sortuj według"
|
||||
class="button"
|
||||
onclick="location.href=\'index.php?module=EcmPriceBooks&action=categoryOrder&record=' . $focus->id . '\';"
|
||||
type="button"
|
||||
name="sort_order"
|
||||
value="Sortuj według">' );
|
||||
require_once ('modules/Currencies/Currency.php');
|
||||
$currency = new Currency ();
|
||||
if (isset ( $focus->exchange_rate_id ) && ! empty ( $focus->exchange_rate_id )) {
|
||||
$currency->retrieve ( $focus->exchange_rate_id );
|
||||
if ($currency->deleted != 1) {
|
||||
$xtpl->assign ( "CURRENCY", $currency->iso4217 . ' ' . $currency->symbol );
|
||||
} else
|
||||
$xtpl->assign ( "CURRENCY", $currency->getDefaultISO4217 () . ' ' . $currency->getDefaultCurrencySymbol () );
|
||||
} else {
|
||||
|
||||
$xtpl->assign ( "CURRENCY", $currency->getDefaultISO4217 () . ' ' . $currency->getDefaultCurrencySymbol () );
|
||||
}
|
||||
|
||||
if ($_SESSION ['pricebook_images'] == "true")
|
||||
$xtpl->assign ( "IMAGES_CHECKED", "checked" );
|
||||
|
||||
global $current_user;
|
||||
|
||||
if (is_admin ( $current_user ) && $_REQUEST ['module'] != 'DynamicLayout' && ! empty ( $_SESSION ['editinplace'] )) {
|
||||
$xtpl->assign ( "ADMIN_EDIT", "<a href='index.php?action=index&module=DynamicLayout&from_action=" . $_REQUEST ['action'] . "&from_module=" . $_REQUEST ['module'] . "&record=" . $_REQUEST ['record'] . "'>" . get_image ( $image_path . "EditLayout", "border='0' alt='Edit Layout' align='bottom'" ) . "</a>" );
|
||||
}
|
||||
|
||||
$result = $db->query ( "select ecmproduct_id,price from ecmpricebooks_ecmproducts where ecmpricebook_id='" . $_REQUEST ['record'] . "' and deleted='0'" );
|
||||
|
||||
$products = "";
|
||||
while ( ($row = $db->fetchByAssoc ( $result )) != null ) {
|
||||
$row1 = $db->fetchByAssoc ( $db->query ( "select name from ecmproducts where id='" . $row ['ecmproduct_id'] . "' and deleted='0'" ) );
|
||||
$products .= $row1 ['name'] . ", price: " . $row ['price'] . "<br>";
|
||||
}
|
||||
$xtpl->assign ( "PRODUCTS", $products );
|
||||
|
||||
$result = $db->query ( "select id,name from ecmpricebooks_customview where name!='' order by name asc" );
|
||||
if (! $_COOKIE ['customview_id'] || $_COOKIE ['customview_id'] == "select" || $_COOKIE ['customview_id'] == "Select") {
|
||||
$rrr = $GLOBALS ['db']->fetchByAssoc ( $GLOBALS ['db']->query ( "select id,name from ecmpricebooks_customview where name!='' order by name asc" ) );
|
||||
setcookie ( "customview_id", $rrr ['id'], time () + 3600 * 24 * 60 );
|
||||
$_COOKIE ['customview_id'] = $rrr ['id'];
|
||||
}
|
||||
$products = "";
|
||||
$cv_select = '<select name="customview" onchange="mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=ListViewProductsAjax&customview_id=\'+this.value+\'&pricebook_id=' . $_REQUEST ['record'] . '&sorder=asc\',\'products\');" id="customview"><option>Select</option>';
|
||||
while ( ($row = $db->fetchByAssoc ( $result )) != null ) {
|
||||
$cv_select .= '<option value="' . $row ['id'] . '"';
|
||||
if ($_COOKIE ['customview_id'] == $row ['id'])
|
||||
$cv_select .= ' selected';
|
||||
$cv_select .= '>' . $row ['name'] . "</option>";
|
||||
}
|
||||
$cv_select .= '</select> <a style="cursor:pointer;" onclick="location.href=\'index.php?module=EcmPriceBooks&action=EditCustomView&record=\'+document.getElementById(\'customview\').value;">' . $mod_strings ['LBL_CV_EDIT'] . '</a> | <a style="cursor:pointer;" onclick="if(confirm(\'' . $mod_strings ['LBL_CV_QUESTION'] . '\'))location.href=\'index.php?module=EcmPriceBooks&action=DeleteCustomView&record=\'+document.getElementById(\'customview\').value;">' . $mod_strings ['LBL_CV_DELETE'] . '</a> | <a style="cursor:pointer;" onclick="location.href=\'index.php?module=EcmPriceBooks&action=EditCustomView\';">' . $mod_strings ['LBL_CV_CREATE'] . '</a><script>mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=ListViewProductsAjax&customview_id=' . $_COOKIE ['customview_id'] . '&pricebook_id=' . $_REQUEST ['record'] . '&sorder=asc\',\'products\');</script>';
|
||||
$xtpl->assign ( "CUSTOMVIEW_SELECT", $cv_select );
|
||||
|
||||
$xtpl->assign ( "CURRENCY_VALUE", $focus->currency_value );
|
||||
$xtpl->assign ( "CREATED_BY", $focus->created_by_name );
|
||||
$xtpl->assign ( "MODIFIED_BY", $focus->modified_by_name );
|
||||
// $xtpl->assign("CATALOGUE",'<input type="button" class="button" value="Create Catalogue PL" onclick="location.href=\'index.php?module=EcmPriceBooks&action=createCatalogue&language=pl&record='.$focus->id.'&to_pdf=1\';"> <input type="button" class="button" value="Create Catalogue EN" onclick="location.href=\'index.php?module=EcmPriceBooks&action=createCatalogue&language=en&record='.$focus->id.'&to_pdf=1\';">');
|
||||
|
||||
$detailView->processListNavigation ( $xtpl, "ECMPRICEBOOKS", $offset, $focus->is_AuditEnabled () );
|
||||
|
||||
// ADDING CUSTOM FIELDS:
|
||||
require_once ('modules/DynamicFields/templates/Files/DetailView.php');
|
||||
|
||||
if (! empty ( $focus->id )) {
|
||||
$merge_button = <<<EOQ
|
||||
<input title="{$app_strings['LBL_DUP_MERGE']}" accessKey="M" class="button" onclick="this.form.return_module.value='EcmPriceBooks'; this.form.return_action.value='DetailView';this.form.return_id.value='{$focus->id}'; this.form.action.value='Step1'; this.form.module.value='MergeRecords';" type="submit" name="Merge" value=" {$app_strings['LBL_DUP_MERGE']} "/>
|
||||
EOQ;
|
||||
$xtpl->assign ( "FIND_DUPES_MERGE_BUTTON", $merge_button );
|
||||
}
|
||||
if ($_REQUEST ['tab'])
|
||||
$xtpl->assign ( "LOAD_TAB", "<script>showBlock('" . $_REQUEST ['tab'] . "');</script>" );
|
||||
$xtpl->parse ( "main" );
|
||||
$xtpl->out ( "main" );
|
||||
|
||||
$sub_xtpl = $xtpl;
|
||||
$old_contents = ob_get_contents ();
|
||||
ob_end_clean ();
|
||||
ob_start ();
|
||||
echo $old_contents;
|
||||
|
||||
require_once ('modules/SavedSearch/SavedSearch.php');
|
||||
$savedSearch = new SavedSearch ();
|
||||
$json = getJSONobj ();
|
||||
$savedSearchSelects = $json->encode ( array (
|
||||
$GLOBALS ['app_strings'] ['LBL_SAVED_SEARCH_SHORTCUT'] . '<br>' . $savedSearch->getSelect ( 'EcmPriceBooks' )
|
||||
) );
|
||||
$str = "<script>
|
||||
YAHOO.util.Event.addListener(window, 'load', SUGAR.util.fillShortcuts, $savedSearchSelects);
|
||||
</script>";
|
||||
echo $str;
|
||||
setcookie ( "pricebook_id", $_REQUEST ['record'], time () + 60 * 24 * 60 * 3600 );
|
||||
$_SESSION ['pricebook_id'] = $_REQUEST ['record'];
|
||||
?>
|
||||
343
modules/EcmPriceBooks2/EcmPriceBook.php
Executable file
343
modules/EcmPriceBooks2/EcmPriceBook.php
Executable file
@@ -0,0 +1,343 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
require_once('data/SugarBean.php');
|
||||
require_once('include/utils.php');
|
||||
|
||||
// SHOULD INCLUDE SELECTIVELY
|
||||
|
||||
|
||||
class EcmPriceBook extends SugarBean {
|
||||
var $field_name_map = array();
|
||||
// STANDARD FIELDS
|
||||
var $id;
|
||||
var $date_entered;
|
||||
var $date_modified;
|
||||
var $modified_user_id;
|
||||
var $assigned_user_id;
|
||||
var $name;
|
||||
|
||||
//TABLE COLUMNS
|
||||
var $active;
|
||||
var $description;
|
||||
var $exchange_rate_name;
|
||||
var $exchange_rate_id;
|
||||
var $account_name;
|
||||
var $account_id;
|
||||
var $lead_name;
|
||||
var $lead_id;
|
||||
var $price;
|
||||
var $ecmlanguage;
|
||||
|
||||
// RELATED FIELDS
|
||||
var $created_by;
|
||||
var $created_by_name;
|
||||
var $modified_by_name;
|
||||
var $assigned_user_name;
|
||||
|
||||
// SUBPANELS RELATED
|
||||
|
||||
// MODULE OBJECT DETAILS
|
||||
var $module_dir = 'EcmPriceBooks';
|
||||
var $table_name = "ecmpricebooks";
|
||||
var $object_name = "EcmPriceBook";
|
||||
|
||||
//RELATED TABLE NAMES
|
||||
|
||||
|
||||
// USED TO RETRIEVE RELATED FIELDS FROM FORM POSTS.
|
||||
var $additional_column_fields = Array(
|
||||
'assigned_user_name',
|
||||
'assigned_user_id',
|
||||
'modified_user_id',
|
||||
'created_by',
|
||||
);
|
||||
|
||||
var $relationship_fields = Array(
|
||||
//RELATIONSHIP FIELDS
|
||||
|
||||
);
|
||||
|
||||
function EcmPriceBook() {
|
||||
if(!$_REQUEST['isDuplicate'] && $_REQUEST['action']=="EditView")$_SESSION['pricebook_duplicate_id']="";
|
||||
parent::SugarBean();
|
||||
$this->setupCustomFields('EcmPriceBooks');
|
||||
foreach ($this->field_defs as $field)
|
||||
{
|
||||
$this->field_name_map[$field['name']] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
var $new_schema = true;
|
||||
|
||||
function get_summary_text(){
|
||||
return "$this->name";
|
||||
}
|
||||
|
||||
function create_list_query($order_by, $where, $show_deleted = 0){
|
||||
// Fill in the assigned_user_name
|
||||
$custom_join = $this->custom_fields->getJOIN();
|
||||
$query = "SELECT ";
|
||||
$query .= "
|
||||
ecmpricebooks.*";
|
||||
if($_REQUEST['pricebook_product_id'])$query.=" ,ecmpricebooks_ecmproducts.price as price";
|
||||
$query.=",users.user_name as assigned_user_name";
|
||||
if($custom_join){
|
||||
$query .= $custom_join['select'];
|
||||
}
|
||||
$query .= " FROM ecmpricebooks
|
||||
LEFT JOIN users
|
||||
ON ecmpricebooks.assigned_user_id=users.id";
|
||||
if($_REQUEST['pricebook_product_id'])$query.=" LEFT JOIN ecmpricebooks_ecmproducts
|
||||
ON ecmpricebooks_ecmproducts.ecmpricebook_id=ecmpricebooks.id";
|
||||
|
||||
|
||||
$query .= " ";
|
||||
if($custom_join){
|
||||
$query .= $custom_join['join'];
|
||||
}
|
||||
$where_auto = '1=1';
|
||||
if($show_deleted == 0){
|
||||
$where_auto = " $this->table_name.deleted=0 ";
|
||||
}else if($show_deleted == 1){
|
||||
$where_auto = " $this->table_name.deleted=1 ";
|
||||
}
|
||||
|
||||
|
||||
if($where != "")
|
||||
$query .= "where $where AND ".$where_auto;
|
||||
else
|
||||
$query .= "where ".$where_auto;
|
||||
if($_REQUEST['pricebook_product_id'])$query.=" AND ecmpricebooks_ecmproducts.ecmproduct_id='".$_REQUEST['pricebook_product_id']."'";
|
||||
//if($_REQUEST['exchange_rate_id'])$query.=" AND ecmpricebooks.exchange_rate_id='".$_REQUEST['exchange_rate_id']."'";
|
||||
if($_GET['pricebook_id'])$query.=" AND ecmpricebooks.id='".$_GET['pricebook_id']."'";
|
||||
if(substr_count($order_by, '.') > 0){
|
||||
$query .= " ORDER BY $order_by";
|
||||
}
|
||||
else if($order_by != "")
|
||||
$query .= " ORDER BY $order_by";
|
||||
else
|
||||
$query .= " ORDER BY ecmpricebooks.name";
|
||||
//echo $query;
|
||||
return $query;
|
||||
}
|
||||
/*
|
||||
function create_new_list_query($order_by, $where, $show_deleted = 0){
|
||||
// Fill in the assigned_user_name
|
||||
$custom_join = $this->custom_fields->getJOIN();
|
||||
|
||||
if($_REQUEST['pricebook_product_id']){
|
||||
$w=$GLOBALS['db']->query("select distinct ecmpricebook_id from ecmpricebooks_ecmproducts where deleted='0' and ecmproduct_id='".$_REQUEST['pricebook_product_id']."'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w))$arr[]="ecmpricebooks.id like '".$r['ecmpricebook_id']."'";
|
||||
$wpr="( ".implode(" or ",$arr)." )";
|
||||
}
|
||||
|
||||
$select = "SELECT ";
|
||||
$select .= "ecmpricebooks.*";
|
||||
$select.=",users.user_name as assigned_user_name";
|
||||
if($custom_join){
|
||||
$select .= $custom_join['select'];
|
||||
}
|
||||
|
||||
$from = " FROM ecmpricebooks LEFT JOIN users ON ecmpricebooks.assigned_user_id=users.id";
|
||||
|
||||
if($custom_join){
|
||||
$from .= $custom_join['join'];
|
||||
}
|
||||
|
||||
$where_auto = '1=1';
|
||||
if($show_deleted == 0){
|
||||
$where_auto = " $this->table_name.deleted=0 ";
|
||||
}
|
||||
else if($show_deleted == 1){
|
||||
$where_auto = " $this->table_name.deleted=1 ";
|
||||
}
|
||||
|
||||
|
||||
if($where != "")
|
||||
$wh= "where $where AND ".$where_auto;
|
||||
else
|
||||
$wh = "where ".$where_auto;
|
||||
|
||||
if($_REQUEST['pricebook_product_id']){
|
||||
$wh.=" and ".$wpr;
|
||||
}
|
||||
|
||||
if(substr_count($order_by, '.') > 0)$ob= " ORDER BY $order_by";
|
||||
else if($order_by != "")$ob = " ORDER BY $order_by";
|
||||
else $ob = " ORDER BY ecmpricebooks.name";
|
||||
|
||||
$query['select']=$select;
|
||||
$query['from']=$from;
|
||||
$query['where']=$wh;
|
||||
$query['order_by']=$ob;
|
||||
|
||||
$GLOBALS['db']->query($query['select']." ".$query['from']." ".$query['where']." ".$query['order_by']);
|
||||
print $query['select']." ".$query['from']." ".$query['where']." ".$query['order_by'];
|
||||
print mysql_error();
|
||||
return $query;
|
||||
}
|
||||
*/
|
||||
function create_export_query($order_by, $where){
|
||||
$custom_join = $this->custom_fields->getJOIN();
|
||||
$query = "SELECT
|
||||
ecmpricebooks.*,
|
||||
users.user_name assigned_user_name";
|
||||
if($custom_join){
|
||||
$query .= $custom_join['select'];
|
||||
}
|
||||
$query .= " FROM ecmpricebooks ";
|
||||
|
||||
$query .= " LEFT JOIN users
|
||||
ON ecmpricebooks.assigned_user_id=users.id";
|
||||
if($custom_join){
|
||||
$query .= $custom_join['join'];
|
||||
}
|
||||
$query .= "";
|
||||
$where_auto = " ecmpricebooks.deleted=0
|
||||
";
|
||||
|
||||
if($where != "")
|
||||
$query .= " where $where AND ".$where_auto;
|
||||
else
|
||||
$query .= " where ".$where_auto;
|
||||
|
||||
if($order_by != "")
|
||||
$query .= " ORDER BY $order_by";
|
||||
else
|
||||
$query .= " ORDER BY ecmpricebooks.name";
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
function fill_in_additional_list_fields(){
|
||||
if ($this->active==1)
|
||||
$this->active='yes';
|
||||
else
|
||||
$this->active='no';
|
||||
}
|
||||
|
||||
function fill_in_additional_detail_fields(){
|
||||
// FILL IN THE ASSIGNED_USER_NAME
|
||||
$this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
|
||||
$this->created_by_name = get_assigned_user_name($this->created_by);
|
||||
$this->modified_by_name = get_assigned_user_name($this->modified_user_id);
|
||||
}
|
||||
|
||||
function get_list_view_data(){
|
||||
global $current_language;
|
||||
$the_array = parent::get_list_view_data();
|
||||
$app_list_strings = return_app_list_strings_language($current_language);
|
||||
$mod_strings = return_module_language($current_language, 'EcmPriceBooks');
|
||||
|
||||
// THE NEW LISTVIEW CODE ONLY FETCHES COLUMNS THAT WE'RE DISPLAYING AND NOT ALL
|
||||
// THE COLUMNS SO WE NEED THESE CHECKS.
|
||||
$the_array['NAME'] = (($this->name == "") ? "<em>blank</em>" : $this->name);
|
||||
$the_array['ENCODED_NAME'] = $this->name;
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select * from ecmpricebooks where id='".$this->id."'"));
|
||||
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($r['exchange_rate_id']);
|
||||
|
||||
$the_array['EXCHANGE_RATE_NAME'] = $currency->iso4217;
|
||||
$w=$GLOBALS['db']->query("select price,recipient_code from ecmpricebooks_ecmproducts where ecmproduct_id='".$_REQUEST['pricebook_product_id']."' and ecmpricebook_id='".$this->id."' and deleted='0'");
|
||||
$r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
//$the_array['LIST_PRICE']=number_format($r['price'],2,$GLOBALS['sugar_config']['default_decimal_seperator'],$GLOBALS['sugar_config']['default_number_grouping_seperator']);
|
||||
$the_array['PRICE']=number_format($r['price'],2,$GLOBALS['sugar_config']['default_decimal_seperator'],$GLOBALS['sugar_config']['default_number_grouping_seperator']);
|
||||
$the_array['RECIPIENT_CODE']=$r['recipient_code'];
|
||||
|
||||
if(mysql_num_rows($w)==0)$the_array['LIST_PRICE']=$mod_strings['LBL_NO_ON_THIS_PRICEBOOK'];
|
||||
require_once("modules/EcmProducts/EcmProduct.php");
|
||||
$prod=new EcmProduct();
|
||||
$prod->retrieve($_REQUEST['pricebook_product_id']);
|
||||
$prod->format_all_fields();
|
||||
$the_array['INDEX']=$prod->product_index;
|
||||
|
||||
return $the_array;
|
||||
}
|
||||
|
||||
/**
|
||||
BUILDS A GENERIC SEARCH BASED ON THE QUERY STRING USING OR.
|
||||
DO NOT INCLUDE ANY $THIS-> BECAUSE THIS IS CALLED ON WITHOUT HAVING THE CLASS INSTANTIATED.
|
||||
*/
|
||||
function build_generic_where_clause ($the_query_string) {
|
||||
$where_clauses = Array();
|
||||
$the_query_string = PearDatabase::quote(from_html($the_query_string));
|
||||
array_push($where_clauses, "ecmpricebooks.name like '$the_query_string%'");
|
||||
|
||||
$the_where = "";
|
||||
foreach($where_clauses as $clause){
|
||||
if($the_where != "") $the_where .= " or ";
|
||||
$the_where .= $clause;
|
||||
}
|
||||
return $the_where;
|
||||
}
|
||||
|
||||
function set_notification_body($xtpl, $simplemodule){
|
||||
global $mod_strings, $app_list_strings;
|
||||
|
||||
$xtpl->assign("NAME", $simplemodule->name);
|
||||
$xtpl->assign("ECMPRICEBOOKS_DESCRIPTION", $ecmpricebooks->description);
|
||||
return $xtpl;
|
||||
}
|
||||
|
||||
function bean_implements($interface){
|
||||
switch($interface){
|
||||
case 'ACL':return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function save($check_notify = FALSE){
|
||||
return parent::save($check_notify);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
99
modules/EcmPriceBooks2/EcmPriceBooksQuickCreate.php
Executable file
99
modules/EcmPriceBooks2/EcmPriceBooksQuickCreate.php
Executable file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/EditView/QuickCreate.php');
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once('include/javascript/javascript.php');
|
||||
|
||||
class EcmPriceBooksQuickCreate extends QuickCreate {
|
||||
|
||||
var $javascript;
|
||||
|
||||
function process() {
|
||||
global $current_user, $timedate, $app_list_strings, $current_language, $mod_strings;
|
||||
$mod_strings = return_module_language($current_language, 'EcmPriceBooks');
|
||||
|
||||
parent::process();
|
||||
|
||||
//BUILDER:START dropdowns setup
|
||||
//BUILDER:END dropdowns setup
|
||||
|
||||
if($this->viaAJAX) { // OVERRIDE FOR AJAX CALL
|
||||
$this->ss->assign('saveOnclick', "onclick='if(check_form(\"ecmpricebooksQuickCreate\")) return SUGAR.subpanelUtils.inlineSave(this.form.id, \"ecmpricebooks\"); else return false;'");
|
||||
$this->ss->assign('cancelOnclick', "onclick='return SUGAR.subpanelUtils.cancelCreate(\"subpanel_ecmpricebooks\")';");
|
||||
}
|
||||
|
||||
$this->ss->assign('viaAJAX', $this->viaAJAX);
|
||||
|
||||
$this->javascript = new javascript();
|
||||
$this->javascript->setFormName('ecmpricebooksQuickCreate');
|
||||
|
||||
$focus = new EcmPriceBook();
|
||||
$this->javascript->setSugarBean($focus);
|
||||
$this->javascript->addAllFields('');
|
||||
|
||||
$this->ss->assign('additionalScripts', $this->javascript->getScript(false));
|
||||
|
||||
$json = getJSONobj();
|
||||
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'ecmpricebooksQuickCreate',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'account_id',
|
||||
'name' => 'account_name',
|
||||
),
|
||||
);
|
||||
|
||||
$encoded_popup_request_data = $json->encode($popup_request_data);
|
||||
$this->ss->assign('encoded_popup_request_data', $encoded_popup_request_data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
229
modules/EcmPriceBooks2/EditCustomView.php
Executable file
229
modules/EcmPriceBooks2/EditCustomView.php
Executable file
@@ -0,0 +1,229 @@
|
||||
<?
|
||||
global $db;
|
||||
|
||||
$result = $db->query("select * from ecmpricebooks_customview where id='".$_REQUEST['record']."'");
|
||||
$row=$db->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
$o=explode("||",$row['orders']);
|
||||
|
||||
$name=$row['name'];
|
||||
|
||||
for($i=0;$i<count($o);$i++){
|
||||
$exp=explode(" ",$o[$i]);
|
||||
$sorder[$i+1]=$exp[1];
|
||||
$oi[$i+1]=$exp[0];
|
||||
}
|
||||
|
||||
|
||||
require("modules/EcmProducts/vardefs.php");
|
||||
require("modules/EcmProducts/language/en_us.lang.php");
|
||||
|
||||
function showSorder($i,$value){
|
||||
require("modules/EcmPriceBooks/language/en_us.lang.php");
|
||||
$html='<select name="sorder'.$i.'">';
|
||||
$html.='<option value="asc"';
|
||||
if($value=="asc")$html.=' selected';
|
||||
$html.='>'.$mod_strings['LBL_ASCENDING'].'</option>';
|
||||
$html.='<option value="desc"';
|
||||
if($value=="desc")$html.=' selected';
|
||||
$html.='>'.$mod_strings['LBL_DESCENDING'].'</option>';
|
||||
$html.='</select>';
|
||||
return $html;
|
||||
}
|
||||
function selectColumn($fields,$i,$value)
|
||||
{
|
||||
for($j=1;$j<=9;$j++)$sos.='showOrderSelect('.$j.',document.getElementById(\'order'.$j.'\').value);';
|
||||
$html='<select onchange="'.$sos.'" name="column'.$i.'" id="column'.$i.'"><option value="">Select</option>';
|
||||
foreach($fields as $field)
|
||||
{
|
||||
if($field['name'] && $field['vname'])
|
||||
{
|
||||
$html.='<option value="'.$field['name'].'"';
|
||||
if($value==$field['name'])$html.=' selected';
|
||||
$html.='>'.$field['vname'].'</option>';
|
||||
}
|
||||
}
|
||||
$html.='</select>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
$fields=$dictionary['EcmProduct']['fields'];
|
||||
$js="";
|
||||
foreach($fields as $field)$f[]=array("vname"=>$mod_strings[$field['vname']],"name"=>$field['name']);
|
||||
$f[]=array("vname"=>$mod_strings['LBL_LIST_PRICE'],"name"=>"list_price");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_MARGIN'],"name"=>"margin_rate");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_RECIPIENT_CODE'],"name"=>"recipient_code");
|
||||
|
||||
$f[]=array("vname"=>$mod_strings['LBL_EAN_PL'],"name"=>"ean_pl");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_SHORT_DESCRIPTION_PL'],"name"=>"short_description_pl");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_LONG_DESCRIPTION_PL'],"name"=>"long_description_pl");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_REMARKS_PL'],"name"=>"remarks_pl");
|
||||
|
||||
$f[]=array("vname"=>$mod_strings['LBL_EAN_EN'],"name"=>"ean_en");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_SHORT_DESCRIPTION_EN'],"name"=>"short_description_en");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_LONG_DESCRIPTION_EN'],"name"=>"long_description_en");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_REMARKS_EN'],"name"=>"remarks_en");
|
||||
|
||||
$f[]=array("vname"=>$mod_strings['LBL_EAN_DE'],"name"=>"ean_de");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_SHORT_DESCRIPTION_DE'],"name"=>"short_description_de");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_LONG_DESCRIPTION_DE'],"name"=>"long_description_de");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_REMARKS_DE'],"name"=>"remarks_de");
|
||||
|
||||
$f[]=array("vname"=>$mod_strings['LBL_DEFAULT_REMARKS_PL'],"name"=>"default_remarks_pl");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_DEFAULT_REMARKS_EN'],"name"=>"default_remarks_en");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_DEFAULT_REMARKS_DE'],"name"=>"default_remarks_de");
|
||||
|
||||
$f[]=array("vname"=>"Qty in last 1 m","name"=>"sale_qty30");
|
||||
$f[]=array("vname"=>"Qty in last 3 m","name"=>"sale_qty90");
|
||||
$f[]=array("vname"=>"Qty in last 6 m","name"=>"sale_qty180");
|
||||
|
||||
$f[]=array("vname"=>"Avg price in last 1 m","name"=>"sale_avg_price30");
|
||||
$f[]=array("vname"=>"Avg price in last 3 m","name"=>"sale_avg_price90");
|
||||
$f[]=array("vname"=>"Avg price in last 6 m","name"=>"sale_avg_price180");
|
||||
|
||||
$f[]=array("vname"=>"Ordered","name"=>"ordered");
|
||||
sort($f);
|
||||
foreach($f as $ff)$js.='names["'.$ff['name'].'"]="'.$ff['vname'].'"
|
||||
';
|
||||
?>
|
||||
<script>
|
||||
function showOrderSelect(no,v)
|
||||
{
|
||||
var names=new Array();
|
||||
<?print $js;?>
|
||||
var html='<select name="order'+no+'" id="order'+no+'"><option value="">select</option>';
|
||||
html=html+'<option value="name"';
|
||||
if("name"==v)
|
||||
{
|
||||
html=html+' selected';
|
||||
}
|
||||
for(var i=1;i<=9;i++)
|
||||
{
|
||||
if(document.getElementById('column'+i).value)
|
||||
{
|
||||
html=html+'<option value="'+document.getElementById('column'+i).value+'"';
|
||||
if(v==document.getElementById('column'+i).value)
|
||||
{
|
||||
html=html+' selected';
|
||||
}
|
||||
html=html+'>'+names[document.getElementById('column'+i).value]+'</option>';
|
||||
}
|
||||
}
|
||||
html=html+'</select>';
|
||||
document.getElementById('dorder'+no).innerHTML=html;
|
||||
return html;
|
||||
}
|
||||
</script>
|
||||
<form name="EditView" method="POST" action="index.php?module=EcmPriceBooks&action=SaveCustomView&record=<?print $_REQUEST['record'];?>">
|
||||
<div style="padding-top: 2px">
|
||||
<input title="Save" class="button" type="submit" name="button" value="Save" >
|
||||
<input title="Cancel" class="button" type="submit" name="button" value="Cancel">
|
||||
</div><br />
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td width="15%" class="dataLabel"><span sugar='slot1'>View name <span class="required">*</span></span sugar='slot'></td>
|
||||
<td width="35%" class="dataField"><span sugar='slot1b'><input name='name' type="text" tabindex='1' size='35' maxlength='50' value="<? print $name; ?>"></span sugar='slot'></td>
|
||||
<td width="15%" class="dataLabel" > </td>
|
||||
<td width="35%" class="dataField"> </td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="dataLabel"><span sugar='slot3'>Choose columns </span sugar='slot'></td>
|
||||
<td class="dataField"> </td>
|
||||
<td valign="top" class="dataLabel"> </td>
|
||||
<td valign="top" class="dataField"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" valign="top" class="dataLabel"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td><?print selectColumn($f,1,$c[0]);?></td>
|
||||
<td><?print selectColumn($f,2,$c[1]);?></td>
|
||||
<td><?print selectColumn($f,3,$c[2]);?>;</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?print selectColumn($f,4,$c[3]);?></td>
|
||||
<td><?print selectColumn($f,5,$c[4]);?></td>
|
||||
<td><?print selectColumn($f,6,$c[5]);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?print selectColumn($f,7,$c[6]);?></td>
|
||||
<td><?print selectColumn($f,8,$c[7]);?></td>
|
||||
<td><?print selectColumn($f,9,$c[8]);?></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" class="dataLabel">Columns titles </td>
|
||||
<td class="dataField"> </td>
|
||||
<td class="dataLabel" valign="top"> </td>
|
||||
<td class="dataField"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" valign="top" class="dataLabel"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td><input name="title1" type="text" id="title1" value="<?print $t[0];?>" size="30" /></td>
|
||||
<td><input name="title2" type="text" id="title2" value="<?print $t[1];?>" size="30" /></td>
|
||||
<td><input name="title3" type="text" id="title3" value="<?print $t[2];?>" size="30" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input name="title4" type="text" id="title4" value="<?print $t[3];?>" size="30" /></td>
|
||||
<td><input name="title5" type="text" id="title5" value="<?print $t[4];?>" size="30" /></td>
|
||||
<td><input name="title6" type="text" id="title6" value="<?print $t[5];?>" size="30" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input name="title7" type="text" id="title7" value="<?print $t[6];?>" size="30" /></td>
|
||||
<td><input name="title8" type="text" id="title8" value="<?print $t[7];?>" size="30" /></td>
|
||||
<td><input name="title9" type="text" id="title9" value="<?print $t[8];?>" size="30" /></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" class="dataLabel">Sort order </td>
|
||||
<td class="dataField"> </td>
|
||||
<td class="dataLabel" valign="top"> </td>
|
||||
<td class="dataField"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" valign="top" class="dataLabel"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td><div style="display:inline;" id="dorder1"></div><? print showSorder(1,$sorder[1]);?></td>
|
||||
<td><div style="display:inline;" id="dorder2"></div><? print showSorder(2,$sorder[2]);?></td>
|
||||
<td><div style="display:inline;" id="dorder3"></div><? print showSorder(3,$sorder[3]);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div style="display:inline;" id="dorder4"></div><? print showSorder(4,$sorder[4]);?></td>
|
||||
<td><div style="display:inline;" id="dorder5"></div><? print showSorder(5,$sorder[5]);?></td>
|
||||
<td><div style="display:inline;" id="dorder6"></div><? print showSorder(6,$sorder[6]);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div style="display:inline;" id="dorder7"></div><? print showSorder(7,$sorder[7]);?></td>
|
||||
<td><div style="display:inline;" id="dorder8"></div><? print showSorder(8,$sorder[8]);?></td>
|
||||
<td><div style="display:inline;" id="dorder9"></div><? print showSorder(9,$sorder[9]);?></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="padding-top: 2px">
|
||||
<input title="Save" class="button" type="submit" name="button" value="Save" >
|
||||
<input title="Cancel" class="button" type="submit" name="button" value="Cancel">
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
showOrderSelect(1,'<?print $oi[1];?>');
|
||||
showOrderSelect(2,'<?print $oi[2];?>');
|
||||
showOrderSelect(3,'<?print $oi[3];?>');
|
||||
showOrderSelect(4,'<?print $oi[4];?>');
|
||||
showOrderSelect(5,'<?print $oi[5];?>');
|
||||
showOrderSelect(6,'<?print $oi[6];?>');
|
||||
showOrderSelect(7,'<?print $oi[7];?>');
|
||||
showOrderSelect(8,'<?print $oi[8];?>');
|
||||
showOrderSelect(9,'<?print $oi[9];?>');
|
||||
</script>
|
||||
368
modules/EcmPriceBooks2/EditView1.php
Executable file
368
modules/EcmPriceBooks2/EditView1.php
Executable file
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
include("modules/EcmProducts/moduleMenu.php");
|
||||
|
||||
// INCLUDE SUPPPORT MODULES
|
||||
require_once('XTemplate/xtpl.php');
|
||||
require_once('data/Tracker.php');
|
||||
|
||||
// INCLUDE MODULE OBJECT AND FORMS
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once('modules/EcmPriceBooks/Forms.php');
|
||||
|
||||
global $app_strings;
|
||||
global $mod_strings;
|
||||
global $mod_strings;
|
||||
global $current_user;
|
||||
global $sugar_version, $sugar_config;
|
||||
global $db;
|
||||
|
||||
echo 'test';
|
||||
// INSTANTIATES THE MODULE CLASSES
|
||||
$focus = new EcmPriceBook();
|
||||
|
||||
// IF PROCESSING AN EXISTING RECORD, RETRIEVE IT
|
||||
if(isset($_REQUEST['record'])) {
|
||||
$focus->retrieve($_REQUEST['record']);
|
||||
$focus->unformat_all_fields();
|
||||
}
|
||||
if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
|
||||
$_SESSION['pricebook_duplicate_id']=$_REQUEST['record'];
|
||||
$focus->id = "";
|
||||
$focus->simplemodule_number = "";
|
||||
echo 't'.$_SESSION['pricebook_duplicate_id'];
|
||||
}
|
||||
|
||||
$prefillArray = array(
|
||||
'priority' => 'priority',
|
||||
'name' => 'name',
|
||||
'description' => 'description',
|
||||
'status' => 'status',
|
||||
'type' => 'type',
|
||||
);
|
||||
|
||||
foreach($prefillArray as $requestKey => $focusVar) {
|
||||
if (isset($_REQUEST[$requestKey]) && is_null($focus->$focusVar)) {
|
||||
$focus->$focusVar = urldecode($_REQUEST[$requestKey]);
|
||||
}
|
||||
}
|
||||
|
||||
// BUILD MODULE TITLE LINE
|
||||
echo "\n<p>\n";
|
||||
echo get_module_title($mod_strings['LBL_MODULE_ID'], $mod_strings['LBL_MODULE_NAME'].": ".$focus->name, true);
|
||||
echo "\n</p>\n";
|
||||
|
||||
global $theme;
|
||||
$theme_path = "themes/".$theme."/";
|
||||
$image_path = $theme_path."images/";
|
||||
require_once ($theme_path.'layout_utils.php');
|
||||
|
||||
$GLOBALS['log']->info("EcmPriceBooks detail view");
|
||||
|
||||
// ASSIGN XTEMPLATE
|
||||
$xtpl = new XTemplate ('modules/EcmPriceBooks/EditView.html');
|
||||
|
||||
// FILL XTEMPLATE MODULE & APPLICATION LANGUAGE STRINGS
|
||||
$xtpl->assign("MOD", $mod_strings);
|
||||
$xtpl->assign("APP", $app_strings);
|
||||
$xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
|
||||
|
||||
if (isset($_REQUEST['return_module'])) $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
|
||||
if (isset($_REQUEST['return_action'])) $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
|
||||
if (isset($_REQUEST['return_id'])) $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
|
||||
|
||||
if (empty($_REQUEST['return_id'])) {
|
||||
$xtpl->assign("RETURN_ACTION", 'index');
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
// SETUP POPUPS START
|
||||
// Users Popup
|
||||
$json = getJSONobj();
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'assigned_user_id',
|
||||
'user_name' => 'assigned_user_name',
|
||||
),
|
||||
);
|
||||
$xtpl->assign('encoded_users_popup_request_data', $json->encode($popup_request_data));
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'account_id',
|
||||
'name' => 'account_name',
|
||||
),
|
||||
);
|
||||
$xtpl->assign('encoded_accounts_popup_request_data', $json->encode($popup_request_data));
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'lead_id',
|
||||
'name' => 'lead_name',
|
||||
),
|
||||
);
|
||||
$xtpl->assign('encoded_leads_popup_request_data', $json->encode($popup_request_data));
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// ACCOUNT_ID WILL BE SET WHEN USER CHOOSES TO CREATE A NEW SIMPLEMODULE FROM ACCOUNT DETAIL VIEW.
|
||||
if (isset($_REQUEST['account_id'])) $xtpl->assign("ACCOUNT_ID", $_REQUEST['account_id']);
|
||||
if (isset($_REQUEST['contact_id'])) $xtpl->assign("CONTACT_ID", $_REQUEST['contact_id']);
|
||||
|
||||
// SET THE CASE_ID, IF SET.
|
||||
// WITH NEW CONCEPT OF SUBPANELS IT,
|
||||
// WHEN THE SUBPANEL IS DISPLAYED IT PULLS FROM THE CLASS NAME WHICH IN THE SITUATION OF CASES IS ACASE SO THE FORM IS GENERATED
|
||||
// WITH ACASE_ID INSTEAD OF CASE_ID, SO I HAVE DONE THE MAPPING HERE
|
||||
if (isset($_REQUEST['acase_id'])) $xtpl->assign("CASE_ID",$_REQUEST['acase_id']);
|
||||
else if(isset($_REQUEST['case_id'])) $xtpl->assign("CASE_ID",$_REQUEST['case_id']);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// QUICK SEARCH SETUP
|
||||
require_once('include/QuickSearchDefaults.php');
|
||||
$qsd = new QuickSearchDefaults();
|
||||
$sqs_objects = array(
|
||||
'assigned_user_name' => $qsd->getQSUser(),
|
||||
|
||||
'account_name' => array(
|
||||
'method' => 'query',
|
||||
'modules' => array('Accounts'),
|
||||
'group' => 'or',
|
||||
'field_list' => array('name', 'id'),
|
||||
'populate_list' => array('account_name', 'account_id'),
|
||||
'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
|
||||
'order' => 'name',
|
||||
'limit' => '30',
|
||||
'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']
|
||||
),
|
||||
'lead_name' => array(
|
||||
'method' => 'query',
|
||||
'modules' => array('Leads'),
|
||||
'group' => 'or',
|
||||
'field_list' => array('last_name', 'id'),
|
||||
'populate_list' => array('lead_name', 'lead_id'),
|
||||
'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
|
||||
'order' => 'last_name',
|
||||
'limit' => '30',
|
||||
'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']
|
||||
),
|
||||
/*
|
||||
//BUILDER:START Pro only
|
||||
'team_name' => $qsd->getQSTeam()
|
||||
//BUILDER:END Pro only
|
||||
*/
|
||||
);
|
||||
$quicksearch_js = $qsd->getQSScripts();
|
||||
$quicksearch_js .= '<script type="text/javascript" language="javascript">sqs_objects = ' . $json->encode($sqs_objects) . '</script>';
|
||||
// QUICK SEARCH SETUP
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ASSIGN GLOBAL VARIABLES
|
||||
$xtpl->assign("THEME", $theme);
|
||||
$xtpl->assign("IMAGE_PATH", $image_path);$xtpl->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
|
||||
$xtpl->assign("JAVASCRIPT", get_set_focus_js().get_validate_record_js(). $quicksearch_js);
|
||||
$xtpl->assign("USER_DATEFORMAT", '('. $timedate->get_user_date_format().')');
|
||||
$xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
|
||||
// ASSIGN GLOBAL VARIABLES
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ASSIGN MODULE DEFAULT VARIABLES
|
||||
|
||||
|
||||
$xtpl->assign("ID", $focus->id);
|
||||
if (!empty($focus->name))
|
||||
$xtpl->assign("NAME", $focus->name);
|
||||
else $xtpl->assign("NAME", "");
|
||||
$xtpl->assign("DATE_ENTERED", $focus->date_entered);
|
||||
$xtpl->assign("DATE_MODIFIED", $focus->date_modified);
|
||||
$xtpl->assign("CREATED_BY", $focus->created_by_name);
|
||||
$xtpl->assign("MODIFIED_BY", $focus->modified_by_name);
|
||||
|
||||
if (empty($focus->assigned_user_id) && empty($focus->id)) $focus->assigned_user_id = $current_user->id;
|
||||
if (empty($focus->assigned_name) && empty($focus->id)) $focus->assigned_user_name = $current_user->user_name;
|
||||
$xtpl->assign("ASSIGNED_USER_OPTIONS", get_select_options_with_id(get_user_array(TRUE, "Active", $focus->assigned_user_id), $focus->assigned_user_id));
|
||||
$xtpl->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
|
||||
$xtpl->assign("ASSIGNED_USER_ID", $focus->assigned_user_id );
|
||||
|
||||
// ASSIGN MODULE SPECIFIC VARIABLES
|
||||
|
||||
if (!empty($_REQUEST['active'])) {
|
||||
$xtpl->assign("ACTIVE", "checked");
|
||||
}
|
||||
|
||||
|
||||
if ($focus->active == '1') $xtpl->assign("ACTIVE", "checked");
|
||||
|
||||
|
||||
$xtpl->assign("DESCRIPTION", $focus->description);
|
||||
|
||||
|
||||
$xtpl->assign("EXCHANGE_RATE_NAME", $focus->exchange_rate_name);
|
||||
|
||||
|
||||
$xtpl->assign("EXCHANGE_RATE_ID", $focus->exchange_rate_id);
|
||||
|
||||
|
||||
$xtpl->assign("ACCOUNT_NAME", $focus->account_name);
|
||||
|
||||
|
||||
$xtpl->assign("ACCOUNT_ID", $focus->account_id);
|
||||
|
||||
|
||||
$xtpl->assign("LEAD_NAME", $focus->lead_name);
|
||||
|
||||
|
||||
$xtpl->assign("LEAD_ID", $focus->lead_id);
|
||||
|
||||
//load currencies
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency_list = $currency->get_full_list('name');
|
||||
$currency->retrieve('-99');
|
||||
if(is_array($currency_list))
|
||||
{
|
||||
$currency_list = array_merge(Array($currency), $currency_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
$currency_list = Array($currency);
|
||||
}
|
||||
$arr = array();
|
||||
foreach($currency_list as $key=>$value)
|
||||
{
|
||||
$arr[$value->id] = $value->name;
|
||||
}
|
||||
$xtpl->assign("EXCHANGE_RATE_ID", get_select_options_with_id($arr, $focus->exchange_rate_id));
|
||||
|
||||
// ASSIGN MODULE DROPDOWNS WITH DEFAULT KEY
|
||||
|
||||
// ASSIGN MODULE VARIABLES AFFECTED BY DUPLICATE ACTION
|
||||
if(!isset($_REQUEST['isDuplicate'])) {
|
||||
$focus->id = "";
|
||||
}
|
||||
|
||||
|
||||
// ASSIGN MODULE DROPDOWNS WITHOUT DEFAULT KEY
|
||||
|
||||
//BUILDER:END of xtpl
|
||||
|
||||
// ADD CUSTOM FIELDS
|
||||
require_once('modules/DynamicFields/templates/Files/EditView.php');
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// USER ASSIGNMENT
|
||||
global $current_user;
|
||||
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
|
||||
$record = '';
|
||||
// USER ASSIGNMENT
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if(!empty($_REQUEST['record'])){
|
||||
$record = $_REQUEST['record'];
|
||||
}
|
||||
$xtpl->assign("ADMIN_EDIT","<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
$xtpl->parse("main");
|
||||
$xtpl->out("main");
|
||||
require_once('include/javascript/javascript.php');
|
||||
$javascript = new javascript();
|
||||
$javascript->setFormName('EditView');
|
||||
$javascript->setSugarBean($focus);
|
||||
$javascript->addAllFields('');
|
||||
|
||||
//BUILDER:START Pro only
|
||||
// $javascript->addFieldGeneric( 'team_name', 'varchar', $app_strings['LBL_TEAM'] ,'true');
|
||||
// $javascript->addToValidateBinaryDependency('team_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_TEAM'], 'false', '', 'team_id');
|
||||
//BUILDER:END Pro only
|
||||
|
||||
$javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ASSIGNED_TO'], 'false', '', 'assigned_user_id');
|
||||
|
||||
echo $javascript->getScript();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// SELECT CHANGES TEXT INPUT FIELD
|
||||
/*
|
||||
$prob_array = $json->encode($app_list_strings['sales_probability_dom']);
|
||||
$prePopProb = '';
|
||||
if(empty($focus->id)) $prePopProb = 'document.getElementsByName(\'sales_stage\')[0].onchange();';
|
||||
echo <<<EOQ
|
||||
<script>
|
||||
prob_array = $prob_array;
|
||||
document.getElementsByName('sales_stage')[0].onchange = function() {
|
||||
if(typeof(document.getElementsByName('sales_stage')[0].value) != "undefined" && prob_array[document.getElementsByName('sales_stage')[0].value]) {
|
||||
document.getElementsByName('probability')[0].value = prob_array[document.getElementsByName('sales_stage')[0].value];
|
||||
}
|
||||
};
|
||||
$prePopProb
|
||||
</script>
|
||||
EOQ;
|
||||
*/
|
||||
//
|
||||
/// SELECT CHANGES TEXT INPUT FIELD
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
require_once('modules/SavedSearch/SavedSearch.php');
|
||||
$savedSearch = new SavedSearch();
|
||||
$json = getJSONobj();
|
||||
$savedSearchSelects = $json->encode(array($GLOBALS['app_strings']['LBL_SAVED_SEARCH_SHORTCUT'] . '<br>' . $savedSearch->getSelect('EcmPriceBooks')));
|
||||
$str = "<script>
|
||||
YAHOO.util.Event.addListener(window, 'load', SUGAR.util.fillShortcuts, $savedSearchSelects);
|
||||
</script>";
|
||||
echo $str;
|
||||
|
||||
?>
|
||||
354
modules/EcmPriceBooks2/EmailSave.php
Executable file
354
modules/EcmPriceBooks2/EmailSave.php
Executable file
@@ -0,0 +1,354 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
* *******************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description:
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
|
||||
* Reserved. Contributor(s): ______________________________________..
|
||||
*********************************************************************************/
|
||||
|
||||
require_once('modules/Emails/Email.php');
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// EMAIL SEND/SAVE SETUP
|
||||
$focus = new Email();
|
||||
|
||||
if(!isset($prefix)) {
|
||||
$prefix = '';
|
||||
}
|
||||
if(isset($_POST[$prefix.'meridiem']) && !empty($_POST[$prefix.'meridiem'])) {
|
||||
$_POST[$prefix.'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix.'time_start'], $timedate->get_time_format(true), $_POST[$prefix.'meridiem']);
|
||||
}
|
||||
//retrieve the record
|
||||
if(isset($_POST['record']) && !empty($_POST['record'])) {
|
||||
$focus->retrieve($_POST['record']);
|
||||
|
||||
}
|
||||
if(isset($_REQUEST['user_id'])) {
|
||||
$focus->assigned_user_id = $_REQUEST['user_id'];
|
||||
}
|
||||
if(!$focus->ACLAccess('Save')){
|
||||
ACLController::displayNoAccess(true);
|
||||
sugar_cleanup(true);
|
||||
}
|
||||
if(!empty($_POST['assigned_user_id']) && ($focus->assigned_user_id != $_POST['assigned_user_id']) && ($_POST['assigned_user_id'] != $current_user->id)) {
|
||||
$check_notify = TRUE;
|
||||
}
|
||||
//populate the fields of this Email
|
||||
$allfields = array_merge($focus->column_fields, $focus->additional_column_fields);
|
||||
foreach($allfields as $field) {
|
||||
if(isset($_POST[$field])) {
|
||||
$value = $_POST[$field];
|
||||
$focus->$field = $value;
|
||||
}
|
||||
}
|
||||
if (!isset($_REQUEST['to_addrs'])) {
|
||||
$_REQUEST['to_addrs'] = "";
|
||||
}
|
||||
if (!isset($_REQUEST['to_addrs_ids'])) {
|
||||
$_REQUEST['to_addrs_ids'] = "";
|
||||
}
|
||||
if (!isset($_REQUEST['to_addrs_names'])) {
|
||||
$_REQUEST['to_addrs_names'] = "";
|
||||
}
|
||||
if (!isset($_REQUEST['to_addrs_emails'])) {
|
||||
$_REQUEST['to_addrs_emails'] = "";
|
||||
}
|
||||
|
||||
//compare the 3 fields and return list of contact_ids to link:
|
||||
$focus->to_addrs_arr = $focus->parse_addrs($_REQUEST['to_addrs'], $_REQUEST['to_addrs_ids'], $_REQUEST['to_addrs_names'], $_REQUEST['to_addrs_emails']);
|
||||
|
||||
// make sure the cc_* and bcc_* fields are at least empty if not set
|
||||
$fields_to_check = array(
|
||||
'cc_addrs',
|
||||
'cc_addrs_ids',
|
||||
'bcc_addrs',
|
||||
'bcc_addrs_ids',
|
||||
'cc_addrs_names',
|
||||
'cc_addrs_emails',
|
||||
'bcc_addrs_emails',
|
||||
);
|
||||
foreach ($fields_to_check as $field_to_check) {
|
||||
if (!isset($_REQUEST[$field_to_check])) {
|
||||
$_REQUEST[$field_to_check] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$focus->cc_addrs_arr = $focus->parse_addrs($_REQUEST['cc_addrs'], $_REQUEST['cc_addrs_ids'], $_REQUEST['cc_addrs_names'], $_REQUEST['cc_addrs_emails']);
|
||||
$focus->bcc_addrs_arr = $focus->parse_addrs($_REQUEST['bcc_addrs'], $_REQUEST['bcc_addrs_ids'], $_REQUEST['to_addrs_names'], $_REQUEST['bcc_addrs_emails']);
|
||||
|
||||
|
||||
if(!empty($_REQUEST['type'])) {
|
||||
$focus->type = $_REQUEST['type'];
|
||||
} elseif(empty($focus->type)) { // cn: from drafts/quotes
|
||||
$focus->type = 'archived';
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// TEMPLATE PARSING
|
||||
// cn: bug 7244 - need to pass an empty bean to parse email templates
|
||||
$object_arr = array();
|
||||
if(!empty($focus->parent_id)) {
|
||||
$object_arr[$focus->parent_type] = $focus->parent_id;
|
||||
}
|
||||
if(isset($focus->to_addrs_arr[0]['contact_id'])) {
|
||||
$object_arr['Contacts'] = $focus->to_addrs_arr[0]['contact_id'];
|
||||
}
|
||||
if(empty($object_arr)) {
|
||||
$object_arr = array('Contacts' => '123');
|
||||
}
|
||||
|
||||
// do not parse email templates if the email is being saved as draft....
|
||||
if($focus->type != 'draft' && count($object_arr) > 0) {
|
||||
require_once($beanFiles['EmailTemplate']);
|
||||
$focus->name = EmailTemplate::parse_template($focus->name, $object_arr);
|
||||
$focus->description = EmailTemplate::parse_template($focus->description, $object_arr);
|
||||
$focus->description_html = EmailTemplate::parse_template($focus->description_html, $object_arr);
|
||||
}
|
||||
//// END TEMPLATE PARSING
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// PREP FOR ATTACHMENTS
|
||||
if(empty($focus->id)){
|
||||
$focus->id = create_guid();
|
||||
$focus->new_with_id = true;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// ATTACHMENT HANDLING
|
||||
$focus->handleAttachments();
|
||||
|
||||
if($_SESSION['pricebook_id'])
|
||||
{
|
||||
$cn=explode(";",$_REQUEST['to_addrs_ids']);
|
||||
if($_REQUEST['attach_pdf'])
|
||||
{
|
||||
$_REQUEST['images']=$_REQUEST['email_images'];
|
||||
include('modules/EcmPriceBooks/CreatePDF.php');
|
||||
if($microtime != '')
|
||||
{
|
||||
require_once('modules/Notes/Note.php');
|
||||
$n = new Note();
|
||||
$n->name = 'Products.pdf';
|
||||
$n->filename = 'Products.pdf';
|
||||
$n->file_mime_type = 'application/pdf';
|
||||
$n->parent_id = $focus->id;
|
||||
$n->parent_type = $focus->module_dir;
|
||||
$n->parent_name = $focus->name;
|
||||
$n->contact_id=trim($cn[0]);
|
||||
$nid=$n->save();
|
||||
|
||||
rename('cache/upload/Products'.$microtime.'.pdf', 'cache/upload/'.$nid);
|
||||
$focus->saved_attachments[] = $n;
|
||||
}
|
||||
}
|
||||
if($_REQUEST['attach_xls'])
|
||||
{
|
||||
include('modules/EcmPriceBooks/CreateXLS.php');
|
||||
if($microtime != '')
|
||||
{
|
||||
require_once('modules/Notes/Note.php');
|
||||
$n = new Note();
|
||||
$n->name = 'Products.xls';
|
||||
$n->filename = 'Products.xls';
|
||||
$n->file_mime_type = 'application/ms-excel';
|
||||
$n->parent_id = $focus->id;
|
||||
$n->parent_type = $focus->module_dir;
|
||||
$n->parent_name = $focus->name;
|
||||
$n->contact_id=trim($cn[0]);
|
||||
$nid=$n->save();
|
||||
|
||||
rename('cache/upload/Products'.$microtime.'.xls', 'cache/upload/'.$nid);
|
||||
$focus->saved_attachments[] = $n;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
}
|
||||
if($_REQUEST['attach_pdf'])
|
||||
{
|
||||
include('modules/EcmPriceBooks/CreateXLS.php');
|
||||
if($microtime != '')
|
||||
{
|
||||
require_once('modules/Notes/Note.php');
|
||||
$n = new Note();
|
||||
$n->name = 'Products.xls';
|
||||
$n->filename = 'Products.xls';
|
||||
$n->file_mime_type = 'application/x-msexcel';
|
||||
$n->parent_id = $focus->id;
|
||||
$n->parent_type = $focus->module_dir;
|
||||
$n->parent_name = $focus->name;
|
||||
$nid=$n->save();
|
||||
|
||||
$focus->saved_attachments[] = $n;
|
||||
rename('cache/upload/Products'.$microtime.'.xls', 'cache/upload/'.$nid);
|
||||
}
|
||||
}
|
||||
*/
|
||||
//// END ATTACHMENT HANDLING
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
$focus->status = 'draft';
|
||||
if($focus->type == 'archived' ) {
|
||||
$focus->status= 'archived';
|
||||
} elseif(($focus->type == 'out' || $focus->type == 'forward')) {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//// REPLY PROCESSING
|
||||
$old = array('<','>');
|
||||
$new = array('<','>');
|
||||
|
||||
if($_REQUEST['from_addr'] != $_REQUEST['from_addr_name'].' <'.$_REQUEST['from_addr_email'].'>') {
|
||||
if(false === strpos($_REQUEST['from_addr'], '<')) { // we have an email only?
|
||||
$focus->from_addr = $_REQUEST['from_addr'];
|
||||
$focus->from_name = '';
|
||||
} else { // we have a compound string
|
||||
$newFromAddr = str_replace($old, $new, $_REQUEST['from_addr']);
|
||||
$focus->from_addr = substr($newFromAddr, (1 + strpos($newFromAddr, '<')), (strpos($newFromAddr, '>') - strpos($newFromAddr, '<')) -1 );
|
||||
$focus->from_name = substr($newFromAddr, 0, (strpos($newFromAddr, '<') -1));
|
||||
}
|
||||
} elseif(!empty($_REQUEST['from_addr_email']) && isset($_REQUEST['from_addr_email'])) {
|
||||
$focus->from_addr = $_REQUEST['from_addr_email'];
|
||||
$focus->from_name = $_REQUEST['from_addr_name'];
|
||||
} else {
|
||||
$focus->from_addr = $focus->getSystemDefaultEmail();
|
||||
}
|
||||
//// REPLY PROCESSING
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
if($focus->send()) {
|
||||
$focus->status = 'sent';
|
||||
} else {
|
||||
$focus->status = 'send_error';
|
||||
}
|
||||
}
|
||||
$focus->to_addrs = $_REQUEST['to_addrs'];
|
||||
|
||||
// delete the existing relationship of all the email addresses with this email
|
||||
$query = "update emails_email_addr_rel set deleted = 1 WHERE email_id = '{$focus->id}'";
|
||||
$focus->db->query($query);
|
||||
|
||||
// delete al the relationship of this email with all the beans
|
||||
$query = "update emails_beans set deleted = 1, bean_id = '', bean_module = '' WHERE email_id = '{$focus->id}'";
|
||||
$focus->db->query($query);
|
||||
|
||||
if(isset($_REQUEST['object_type']) && !empty($_REQUEST['object_type']) && isset($_REQUEST['object_id']) && !empty($_REQUEST['object_id'])) {
|
||||
//run linking code only if the object_id has not been linked as part of the contacts above
|
||||
$GLOBALS['log']->debug("CESELY".$_REQUEST['object_type']);
|
||||
if(!in_array($_REQUEST['object_id'],$exContactIds)){
|
||||
$rel = strtolower($_REQUEST['object_type']);
|
||||
$focus->load_relationship($rel);
|
||||
$focus->$rel->add($_REQUEST['object_id']);
|
||||
$GLOBALS['log']->debug("CESELY LOADED".$_REQUEST['object_type']);
|
||||
}
|
||||
}
|
||||
//// handle legacy parent_id/parent_type relationship calls
|
||||
elseif(isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
|
||||
//run linking code only if the object_id has not been linked as part of the contacts above
|
||||
if(!isset($exContactIds) || !in_array($_REQUEST['parent_id'],$exContactIds)){
|
||||
$rel = strtolower($_REQUEST['parent_type']);
|
||||
$focus->load_relationship($rel);
|
||||
$focus->$rel->add($_REQUEST['parent_id']);
|
||||
}
|
||||
}
|
||||
//// END RELATIONSHIP LINKING
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// If came from email archiving edit view, this would have been set from form input.
|
||||
if (!isset($focus->date_start))
|
||||
{
|
||||
$today = gmdate('Y-m-d H:i:s');
|
||||
$focus->date_start = $timedate->to_display_date($today);
|
||||
$focus->time_start = $timedate->to_display_time($today, true);
|
||||
}
|
||||
|
||||
$focus->date_sent = "";
|
||||
$focus->save(false);
|
||||
//// END EMAIL SAVE/SEND SETUP
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// RELATIONSHIP LINKING
|
||||
$focus->load_relationship('users');
|
||||
$focus->users->add($current_user->id);
|
||||
|
||||
if(!empty($_REQUEST['to_addrs_ids'])) {
|
||||
$focus->load_relationship('contacts');
|
||||
$exContactIds = explode(';', $_REQUEST['to_addrs_ids']);
|
||||
foreach($exContactIds as $contactId) {
|
||||
$contactId = trim($contactId);
|
||||
$focus->contacts->add($contactId);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// PAGE REDIRECTION
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
$return_id = $focus->id;
|
||||
|
||||
if(empty($_POST['return_module'])) {
|
||||
$return_module = "Emails";
|
||||
} else {
|
||||
$return_module = $_POST['return_module'];
|
||||
}
|
||||
if(empty($_POST['return_action'])) {
|
||||
$return_action = "DetailView";
|
||||
} else {
|
||||
$return_action = $_POST['return_action'];
|
||||
}
|
||||
$GLOBALS['log']->debug("Saved record with id of ".$return_id);
|
||||
require_once('include/formbase.php');
|
||||
if($focus->type == 'draft') {
|
||||
if($return_module == 'Emails') {
|
||||
header("Location: index.php?module=$return_module&action=ListViewDrafts");
|
||||
} else {
|
||||
handleRedirect($return_id, 'Emails');
|
||||
}
|
||||
} elseif($focus->type == 'out') {
|
||||
if($return_module == 'Home') {
|
||||
header('Location: index.php?module='.$return_module.'&action=index');
|
||||
}
|
||||
if(!empty($_REQUEST['return_id'])) {
|
||||
$return_id = $_REQUEST['return_id'];
|
||||
}
|
||||
header('Location: index.php?action='.$return_action.'&module='.$return_module.'&record='.$return_id.'&assigned_user_id='.$current_user->id.'&type=inbound');
|
||||
} elseif(isset($_POST['return_id']) && $_POST['return_id'] != "") {
|
||||
$return_id = $_POST['return_id'];
|
||||
}
|
||||
header("Location: index.php?module=EcmPriceBooks&action=Emails&to_pdf=1&bodyclass=tabForm&type=out&pricebook_id=".$_REQUEST['pricebook_id']);
|
||||
?>
|
||||
894
modules/EcmPriceBooks2/Emails.php
Executable file
894
modules/EcmPriceBooks2/Emails.php
Executable file
@@ -0,0 +1,894 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* EditView for Email
|
||||
*
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
$toTemplate = '';
|
||||
if(isset($_REQUEST['pTypeTo']) && $_REQUEST['pTypeTo']!='' && isset($_REQUEST['pIdTo']) && $_REQUEST['pIdTo']!='') {
|
||||
if($_REQUEST['pTypeTo'] == "Accounts") {
|
||||
require_once('modules/Accounts/Account.php');
|
||||
$acc = new Account();
|
||||
$acc->retrieve($_REQUEST['pIdTo']);
|
||||
if(isset($acc->id) && $acc->id!='') {
|
||||
$_REQUEST['to_addrs'] = $acc->name.' <'.$acc->email1.'>; ';
|
||||
}
|
||||
}
|
||||
if($_REQUEST['pTypeTo'] == "Contacts") {
|
||||
require_once('modules/Contacts/Contact.php');
|
||||
$con = new Contact();
|
||||
$con->retrieve($_REQUEST['pIdTo']);
|
||||
if(isset($con->id) && $con->id!='') {
|
||||
$_REQUEST['to_addrs'] = $con->name.' <'.$con->email1.'>; ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['pTypeTo']) && $_REQUEST['pTypeTo']!='')
|
||||
if($_REQUEST['pTypeTo'] == "Accounts") $toTemplate = 'InvoiceTemplateAccount';
|
||||
else
|
||||
if($_REQUEST['pTypeTo'] == "Contacts") $toTemplate = 'InvoiceTemplateContact';
|
||||
|
||||
|
||||
if(isset($_REQUEST['pTypeFrom']) && $_REQUEST['pTypeFrom']!='' && isset($_REQUEST['pIdFrom']) && $_REQUEST['pIdFrom']!='') {
|
||||
if($_REQUEST['pTypeFrom'] == "Users") {
|
||||
require_once('modules/Users/User.php');
|
||||
$us = new User();
|
||||
global $current_user;
|
||||
$us->retrieve($current_user->id);//$_REQUEST['pIdFrom']);
|
||||
if(isset($us->id) && $us->id!='') {
|
||||
$_REQUEST['from_addr'] = $us->name.' <'.$us->email1.'>; ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo '<script type="text/javascript">var asynchronous_key = "'.$_SESSION['asynchronous_key'].'";</script>';
|
||||
|
||||
$GLOBALS['log']->info("Email edit view");
|
||||
|
||||
require_once('include/SugarTinyMCE.php');
|
||||
require_once('modules/Emails/Email.php');
|
||||
require_once('modules/EmailTemplates/EmailTemplate.php');
|
||||
require_once('XTemplate/xtpl.php');
|
||||
|
||||
global $theme;
|
||||
$theme_path="themes/".$theme."/";
|
||||
$image_path=$theme_path."images/";
|
||||
require_once($theme_path.'layout_utils.php');
|
||||
|
||||
global $app_strings;
|
||||
global $app_list_strings;
|
||||
global $current_user;
|
||||
global $sugar_version, $sugar_config;
|
||||
global $timedate;
|
||||
$mod_strings = return_module_language($current_language, 'Emails');
|
||||
|
||||
$OPT = array();
|
||||
if(isset($_REQUEST['invoiceout_id']) && $_REQUEST['invoiceout_id']!='') {
|
||||
$OPT['invoiceout_id'] = $_REQUEST['invoiceout_id'];
|
||||
} else $OPT['invoiceout_id'] = '';
|
||||
|
||||
if(isset($_REQUEST['sended']) && $_REQUEST['sended']!='') {
|
||||
$OPT['sended'] = $_REQUEST['sended'];
|
||||
} else $OPT['sended'] = '0';
|
||||
|
||||
|
||||
$json = getJSONobj();
|
||||
echo '<script language="javascript">
|
||||
|
||||
var OPT = '.$json->encode($OPT).';
|
||||
function invoiceoutAlert(method) {
|
||||
if(OPT[\'invoiceout_id\']==\'\') {
|
||||
alert(\'Invoice not saved!\');
|
||||
return false;
|
||||
}
|
||||
if(method == \'save\') {
|
||||
prepSave(); document.forms.EditView.action.value=\'EmailSave\'; document.forms.EditView.send.value=\'1\'; document.forms.EditView.type.value=\'out\'; return fill_form(\'out\', \''.$mod_strings['ERR_NOT_ADDRESSED'].'\');
|
||||
}
|
||||
if(method == \'save_draft\') {
|
||||
document.forms.EditView.action.value=\'EmailSave\'; document.forms.EditView.send.value=\'0\'; document.forms.EditView.type.value=\'draft\'; fill_form(\'draft\', \''.$mod_strings['ERR_NOT_ADDRESSED'].'\');
|
||||
}
|
||||
};
|
||||
if(OPT[\'sended\']==\'1\') alert(\'Email was sended\');
|
||||
</script>';
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// PREPROCESS BEAN DATA FOR DISPLAY
|
||||
$focus = new Email();
|
||||
$email_type = 'archived';
|
||||
|
||||
if(isset($_REQUEST['record'])) {
|
||||
$focus->retrieve($_REQUEST['record']);
|
||||
}
|
||||
if(!empty($_REQUEST['type'])) {
|
||||
$email_type = $_REQUEST['type'];
|
||||
} elseif(!empty($focus->id)) {
|
||||
$email_type = $focus->type;
|
||||
}
|
||||
|
||||
$focus->type = $email_type;
|
||||
|
||||
//needed when creating a new email with default values passed in
|
||||
if(isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
|
||||
$focus->contact_name = $_REQUEST['contact_name'];
|
||||
}
|
||||
|
||||
if(!empty($_REQUEST['load_id']) && !empty($beanList[$_REQUEST['load_module']])) {
|
||||
$class_name = $beanList[$_REQUEST['load_module']];
|
||||
require_once($beanFiles[$class_name]);
|
||||
$contact = new $class_name();
|
||||
if($contact->retrieve($_REQUEST['load_id'])) {
|
||||
$link_id = $class_name . '_id';
|
||||
$focus->$link_id = $_REQUEST['load_id'];
|
||||
$focus->contact_name = (isset($contact->full_name)) ? $contact->full_name : $contact->name;
|
||||
$focus->to_addrs_names = $focus->contact_name;
|
||||
$focus->to_addrs_ids = $_REQUEST['load_id'];
|
||||
//Retrieve the email address.
|
||||
//If Opportunity or Case then Oppurtinity/Case->Accounts->(email_addr_bean_rel->email_addresses)
|
||||
//If Contacts, Leads etc.. then Contact->(email_addr_bean_rel->email_addresses)
|
||||
$sugarEmailAddress = new SugarEmailAddress();
|
||||
if($class_name == 'Opportunity' || $class_name == 'aCase'){
|
||||
$account = new Account();
|
||||
if($contact->account_id != null && $account->retrieve($contact->account_id)){
|
||||
$sugarEmailAddress->handleLegacyRetrieve($account);
|
||||
if(isset($account->email1)){
|
||||
$focus->to_addrs_emails = $account->email1;
|
||||
$focus->to_addrs = "$focus->contact_name <$account->email1>";
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$sugarEmailAddress->handleLegacyRetrieve($contact);
|
||||
if(isset($contact->email1)){
|
||||
$focus->to_addrs_emails = $contact->email1;
|
||||
$focus->to_addrs = "$focus->contact_name <$contact->email1>";
|
||||
}
|
||||
}
|
||||
if(!empty($_REQUEST['parent_type']) && empty($app_list_strings['record_type_display'][$_REQUEST['parent_type']])){
|
||||
if(!empty($app_list_strings['record_type_display'][$_REQUEST['load_module']])){
|
||||
$_REQUEST['parent_type'] = $_REQUEST['load_module'];
|
||||
$_REQUEST['parent_id'] = $focus->contact_id;
|
||||
$_REQUEST['parent_name'] = $focus->to_addrs_names;
|
||||
} else {
|
||||
unset($_REQUEST['parent_type']);
|
||||
unset($_REQUEST['parent_id']);
|
||||
unset($_REQUEST['parent_name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
|
||||
$focus->contact_id = $_REQUEST['contact_id'];
|
||||
}
|
||||
if(isset($_REQUEST['parent_name'])) {
|
||||
$focus->parent_name = $_REQUEST['parent_name'];
|
||||
}
|
||||
if(isset($_REQUEST['parent_id'])) {
|
||||
$focus->parent_id = $_REQUEST['parent_id'];
|
||||
}
|
||||
if(isset($_REQUEST['parent_type'])) {
|
||||
$focus->parent_type = $_REQUEST['parent_type'];
|
||||
}
|
||||
elseif(is_null($focus->parent_type)) {
|
||||
$focus->parent_type = $app_list_strings['record_type_default_key'];
|
||||
}
|
||||
if(isset($_REQUEST['to_email_addrs'])) {
|
||||
$focus->to_addrs = $_REQUEST['to_email_addrs'];
|
||||
}
|
||||
// needed when clicking through a Contacts detail view:
|
||||
if(isset($_REQUEST['to_addrs_ids'])) {
|
||||
$focus->to_addrs_ids = $_REQUEST['to_addrs_ids'];
|
||||
}
|
||||
if(isset($_REQUEST['to_addrs_emails'])) {
|
||||
$focus->to_addrs_emails = $_REQUEST['to_addrs_emails'];
|
||||
}
|
||||
if(isset($_REQUEST['to_addrs_names'])) {
|
||||
$focus->to_addrs_names = $_REQUEST['to_addrs_names'];
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['to_addrs'])) {
|
||||
$focus->to_addrs = $_REQUEST['to_addrs'];
|
||||
}// user's email, go through 3 levels of precedence:
|
||||
if(isset($_REQUEST['from_addr'])) {
|
||||
$focus->from_addr = $_REQUEST['from_addr'];
|
||||
}// user's email, go through 3 levels of precedence:
|
||||
$from = $current_user->getEmailInfo();
|
||||
//// END PREPROCESSING
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// XTEMPLATE ASSIGNMENT
|
||||
if($email_type == 'archived') {
|
||||
// echo get_module_title('Emails', $mod_strings['LBL_ARCHIVED_MODULE_NAME'].":", true);
|
||||
$xtpl=new XTemplate('modules/Emails/EditViewArchive.html');
|
||||
} else {
|
||||
// echo get_module_title('Emails', $mod_strings['LBL_COMPOSE_MODULE_NAME'].":", true);
|
||||
$xtpl=new XTemplate('modules/EcmPriceBooks/Emails.html');
|
||||
}
|
||||
echo "\n</p>\n";
|
||||
|
||||
// CHECK USER'S EMAIL SETTINGS TO ENABLE/DISABLE 'SEND' BUTTON
|
||||
if(!$focus->check_email_settings() &&($email_type == 'out' || $email_type == 'draft')) {
|
||||
print "<font color='red'>".$mod_strings['WARNING_SETTINGS_NOT_CONF']." <a href='index.php?module=Users&action=EditView&record=".$current_user->id."&return_module=Emails&type=out&return_action=EditView'>".$mod_strings['LBL_EDIT_MY_SETTINGS']."</a></font>";
|
||||
$xtpl->assign("DISABLE_SEND", 'DISABLED');
|
||||
}
|
||||
|
||||
// CHECK THAT SERVER HAS A PLACE TO PUT UPLOADED TEMP FILES SO THAT ATTACHMENTS WILL WORK
|
||||
// cn: Bug 5995
|
||||
$tmpUploadDir = ini_get('upload_tmp_dir');
|
||||
if(!empty($tmpUploadDir)) {
|
||||
if(!is_writable($tmpUploadDir)) {
|
||||
echo "<font color='red'>{$mod_strings['WARNING_UPLOAD_DIR_NOT_WRITABLE']}</font>";
|
||||
}
|
||||
} else {
|
||||
//echo "<font color='red'>{$mod_strings['WARNING_NO_UPLOAD_DIR']}</font>";
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// INBOUND EMAIL HANDLING
|
||||
if(isset($_REQUEST['email_name'])) {
|
||||
$name = str_replace('_',' ',$_REQUEST['email_name']);
|
||||
}
|
||||
if(isset($_REQUEST['inbound_email_id'])) {
|
||||
$ieMail = new Email();
|
||||
$ieMail->retrieve($_REQUEST['inbound_email_id']);
|
||||
|
||||
$invoiceoutd = '';
|
||||
// cn: bug 9725: replies/forwards lose real content
|
||||
$invoiceoutdHtml = $ieMail->invoiceoutHtmlEmail($ieMail->description_html);
|
||||
|
||||
// plain-text
|
||||
$desc = nl2br(trim($ieMail->description));
|
||||
|
||||
$exDesc = explode('<br />', $desc);
|
||||
foreach($exDesc as $k => $line) {
|
||||
$invoiceoutd .= '> '.trim($line)."\r";
|
||||
}
|
||||
|
||||
// prefill empties with the other's contents
|
||||
if(empty($invoiceoutdHtml) && !empty($invoiceoutd)) {
|
||||
$invoiceoutdHtml = nl2br($invoiceoutd);
|
||||
}
|
||||
if(empty($invoiceoutd) && !empty($invoiceoutdHtml)) {
|
||||
$invoiceoutd = strip_tags(br2nl($invoiceoutdHtml));
|
||||
}
|
||||
|
||||
// forwards have special text
|
||||
if($_REQUEST['type'] == 'forward') {
|
||||
$header = $ieMail->getForwardHeader();
|
||||
// subject is handled in Subject line handling below
|
||||
} else {
|
||||
// we have a reply in focus
|
||||
$header = $ieMail->getReplyHeader();
|
||||
}
|
||||
|
||||
$invoiceoutd = br2nl($header.$invoiceoutd);
|
||||
$invoiceoutdHtml = $header.$invoiceoutdHtml;
|
||||
|
||||
|
||||
// if not a forward: it's a reply
|
||||
if($_REQUEST['type'] != 'forward') {
|
||||
$ieMailName = 'RE: '.$ieMail->name;
|
||||
} else {
|
||||
$ieMailName = $ieMail->name;
|
||||
}
|
||||
|
||||
$focus->id = null; // nulling this to prevent overwriting a replied email(we're basically doing a "Duplicate" function)
|
||||
$focus->to_addrs = $ieMail->from_addr;
|
||||
$focus->description = $invoiceoutd; // don't know what i was thinking: ''; // this will be filled on save/send
|
||||
$focus->description_html = $invoiceoutdHtml; // cn: bug 7357 - htmlentities() breaks FCKEditor
|
||||
$focus->parent_type = $ieMail->parent_type;
|
||||
$focus->parent_id = $ieMail->parent_id;
|
||||
$focus->parent_name = $ieMail->parent_name;
|
||||
$focus->name = $ieMailName;
|
||||
$xtpl->assign('INBOUND_EMAIL_ID',$_REQUEST['inbound_email_id']);
|
||||
// un/READ flags
|
||||
if(!empty($ieMail->status)) {
|
||||
// "Read" flag for InboundEmail
|
||||
if($ieMail->status == 'unread') {
|
||||
// creating a new instance here to avoid data corruption below
|
||||
$e = new Email();
|
||||
$e->retrieve($ieMail->id);
|
||||
$e->status = 'read';
|
||||
$e->save();
|
||||
$email_type = $e->status;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//// PRIMARY PARENT LINKING
|
||||
if(empty($focus->parent_type) && empty($focus->parent_id)) {
|
||||
$focus->fillPrimaryParentFields();
|
||||
}
|
||||
//// END PRIMARY PARENT LINKING
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// setup for my/mailbox email switcher
|
||||
$mbox = $ieMail->getMailboxDefaultEmail();
|
||||
$user = $current_user->getPreferredEmail();
|
||||
$useGroup = ' <input id="use_mbox" name="use_mbox" type="checkbox" CHECKED onClick="switchEmail()" >
|
||||
<script type="text/javascript">
|
||||
function switchEmail() {
|
||||
var mboxName = "'.$mbox['name'].'";
|
||||
var mboxAddr = "'.$mbox['email'].'";
|
||||
var userName = "'.$user['name'].'";
|
||||
var userAddr = "'.$user['email'].'";
|
||||
|
||||
if(document.getElementById("use_mbox").checked) {
|
||||
document.getElementById("from_addr_field").value = mboxName + " <" + mboxAddr + ">";
|
||||
document.getElementById("from_addr_name").value = mboxName;
|
||||
document.getElementById("from_addr_email").value = mboxAddr;
|
||||
} else {
|
||||
document.getElementById("from_addr_field").value = userName + " <" + userAddr + ">";
|
||||
document.getElementById("from_addr_name").value = userName;
|
||||
document.getElementById("from_addr_email").value = userAddr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>';
|
||||
$useGroup .= $mod_strings['LBL_USE_MAILBOX_INFO'];
|
||||
|
||||
$xtpl->assign('FROM_ADDR_GROUP', $useGroup);
|
||||
}
|
||||
//// END INBOUND EMAIL HANDLING
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// SUBJECT FIELD MANIPULATION
|
||||
$name = '';
|
||||
if(!empty($_REQUEST['parent_id']) && !empty($_REQUEST['parent_type'])) {
|
||||
$focus->parent_id = $_REQUEST['parent_id'];
|
||||
$focus->parent_type = $_REQUEST['parent_type'];
|
||||
}
|
||||
if(!empty($focus->parent_id) && !empty($focus->parent_type)) {
|
||||
if($focus->parent_type == 'Cases') {
|
||||
require_once('modules/Cases/Case.php');
|
||||
$myCase = new aCase();
|
||||
$myCase->retrieve($focus->parent_id);
|
||||
$myCaseMacro = $myCase->getEmailSubjectMacro();
|
||||
if(isset($ieMail->name) && !empty($ieMail->name)) { // if replying directly to an InboundEmail
|
||||
$oldEmailSubj = $ieMail->name;
|
||||
} elseif(isset($_REQUEST['parent_name']) && !empty($_REQUEST['parent_name'])) {
|
||||
$oldEmailSubj = $_REQUEST['parent_name'];
|
||||
} else {
|
||||
$oldEmailSubj = $focus->name; // replying to an email using old subject
|
||||
}
|
||||
|
||||
if(!preg_match('/^re:/i', $oldEmailSubj)) {
|
||||
$oldEmailSubj = 'RE: '.$oldEmailSubj;
|
||||
}
|
||||
$focus->name = $oldEmailSubj;
|
||||
|
||||
if(strpos($focus->name, str_replace('%1',$myCase->case_number,$myCaseMacro))) {
|
||||
$name = $focus->name;
|
||||
} else {
|
||||
$name = $focus->name.' '.str_replace('%1',$myCase->case_number,$myCaseMacro);
|
||||
}
|
||||
} else {
|
||||
$name = $focus->name;
|
||||
}
|
||||
} else {
|
||||
if(empty($focus->name)) {
|
||||
$name = '';
|
||||
} else {
|
||||
$name = $focus->name;
|
||||
}
|
||||
}
|
||||
if($email_type == 'forward') {
|
||||
$name = 'FW: '.$name;
|
||||
}
|
||||
//// END SUBJECT FIELD MANIPULATION
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// GENERAL TEMPLATE ASSIGNMENTS
|
||||
$xtpl->assign('MOD', return_module_language($current_language, 'Emails'));
|
||||
$xtpl->assign('APP', $app_strings);
|
||||
|
||||
if(!isset($focus->id)) $xtpl->assign('USER_ID', $current_user->id);
|
||||
if(!isset($focus->id) && isset($_REQUEST['contact_id'])) $xtpl->assign('CONTACT_ID', $_REQUEST['contact_id']);
|
||||
|
||||
$xtpl->assign("INVOICEOUT_ID",$_REQUEST['invoiceout_id']);
|
||||
if(isset($_REQUEST['return_module']) && !empty($_REQUEST['return_module'])) {
|
||||
$xtpl->assign('RETURN_MODULE', $_REQUEST['return_module']);
|
||||
} else {
|
||||
$xtpl->assign('RETURN_MODULE', 'Emails');
|
||||
}
|
||||
if(isset($_REQUEST['return_action']) && !empty($_REQUEST['return_action']) && ($_REQUEST['return_action'] != 'SubPanelViewer')) {
|
||||
$xtpl->assign('RETURN_ACTION', $_REQUEST['return_action']);
|
||||
} else {
|
||||
$xtpl->assign('RETURN_ACTION', 'DetailView');
|
||||
}
|
||||
if(isset($_REQUEST['return_id']) && !empty($_REQUEST['return_id'])) {
|
||||
$xtpl->assign('RETURN_ID', $_REQUEST['return_id']);
|
||||
}
|
||||
// handle Create $module then Cancel
|
||||
if(empty($_REQUEST['return_id']) && !isset($_REQUEST['type'])) {
|
||||
$xtpl->assign('RETURN_ACTION', 'index');
|
||||
}
|
||||
|
||||
$xtpl->assign('THEME', $theme);
|
||||
$xtpl->assign('IMAGE_PATH', $image_path);$xtpl->assign('PRINT_URL', 'index.php?'.$GLOBALS['request_string']);
|
||||
|
||||
if(isset($_REQUEST['bodyclass']) && $_REQUEST['bodyclass'] != '') $xtpl->assign('BODYCLASS',$_REQUEST['bodyclass']);
|
||||
|
||||
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
$m = new EcmPriceBook();
|
||||
//$mfp = $m->loadParserArray('email');
|
||||
$xtpl->assign("MFP",$mfp);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// QUICKSEARCH CODE
|
||||
require_once('include/QuickSearchDefaults.php');
|
||||
$qsd = new QuickSearchDefaults();
|
||||
$sqs_objects = array('parent_name' => $qsd->getQSParent(),
|
||||
'assigned_user_name' => $qsd->getQSUser(),
|
||||
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
$json = getJSONobj();
|
||||
|
||||
$quicksearch_js = $qsd->getQSScripts();
|
||||
$sqs_objects_encoded = $json->encode($sqs_objects);
|
||||
$quicksearch_js .= <<<EOQ
|
||||
<script type="text/javascript" language="javascript">sqs_objects = $sqs_objects_encoded;
|
||||
function changeQS() {
|
||||
//new_module = document.getElementById('parent_type').value;
|
||||
new_module = document.EditView.parent_type.value;
|
||||
if(new_module == 'Contacts' || new_module == 'Leads' || typeof(disabledModules[new_module]) != 'undefined') {
|
||||
sqs_objects['parent_name']['disable'] = true;
|
||||
document.getElementById('parent_name').readOnly = true;
|
||||
}
|
||||
else {
|
||||
sqs_objects['parent_name']['disable'] = false;
|
||||
document.getElementById('parent_name').readOnly = false;
|
||||
}
|
||||
|
||||
sqs_objects['parent_name']['module'] = new_module;
|
||||
}
|
||||
changeQS();
|
||||
</script>
|
||||
EOQ;
|
||||
$xtpl->assign('JAVASCRIPT', get_set_focus_js().$quicksearch_js);
|
||||
//// END QUICKSEARCH CODE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// cn: bug 14191 - duping archive emails overwrites the original
|
||||
if(!isset($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] != 'true') {
|
||||
$xtpl->assign('ID', $focus->id);
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
|
||||
$xtpl->assign('OBJECT_ID', $_REQUEST['parent_id']);
|
||||
$xtpl->assign('OBJECT_TYPE', $_REQUEST['parent_type']);
|
||||
}
|
||||
|
||||
$xtpl->assign('FROM_ADDR', $focus->from_addr);
|
||||
$xtpl->assign('FROM_ADDR', $current_user->first_name." ".$current_user->last_name." <". $current_user->getPreference('mail_fromaddress').">");
|
||||
//// prevent TO: prefill when type is 'forward'
|
||||
if($email_type != 'forward') {
|
||||
$xtpl->assign('TO_ADDRS', $focus->to_addrs);
|
||||
$xtpl->assign('FROM_ADDRS', $focus->from_addrs);
|
||||
$xtpl->assign('TO_ADDRS_IDS', $focus->to_addrs_ids);
|
||||
$xtpl->assign('TO_ADDRS_NAMES', $focus->to_addrs_names);
|
||||
$xtpl->assign('TO_ADDRS_EMAILS', $focus->to_addrs_emails);
|
||||
$xtpl->assign('CC_ADDRS', $focus->cc_addrs);
|
||||
$xtpl->assign('CC_ADDRS_IDS', $focus->cc_addrs_ids);
|
||||
$xtpl->assign('CC_ADDRS_NAMES', $focus->cc_addrs_names);
|
||||
$xtpl->assign('CC_ADDRS_EMAILS', $focus->cc_addrs_emails);
|
||||
$xtpl->assign('BCC_ADDRS', $focus->bcc_addrs);
|
||||
$xtpl->assign('BCC_ADDRS_IDS', $focus->bcc_addrs_ids);
|
||||
$xtpl->assign('BCC_ADDRS_NAMES', $focus->bcc_addrs_names);
|
||||
$xtpl->assign('BCC_ADDRS_EMAILS', $focus->bcc_addrs_emails);
|
||||
}
|
||||
|
||||
//$xtpl->assign('FROM_ADDR', $from['name'].' <'.$from['email'].'>');
|
||||
$xtpl->assign('FROM_ADDR_NAME', $from['name']);
|
||||
$xtpl->assign('FROM_ADDR_EMAIL', $from['email']);
|
||||
|
||||
$xtpl->assign('NAME', from_html($name));
|
||||
//$xtpl->assign('DESCRIPTION_HTML', from_html($focus->description_html));
|
||||
$xtpl->assign('DESCRIPTION', $focus->description);
|
||||
$xtpl->assign('TYPE',$email_type);
|
||||
|
||||
// Unimplemented until jscalendar language files are fixed
|
||||
// $xtpl->assign('CALENDAR_LANG',((empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language]));
|
||||
$xtpl->assign('CALENDAR_LANG', 'en');
|
||||
$xtpl->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format());
|
||||
$xtpl->assign('DATE_START', $focus->date_start);
|
||||
$xtpl->assign('TIME_FORMAT', '('. $timedate->get_user_time_format().')');
|
||||
$xtpl->assign('TIME_START', substr($focus->time_start,0,5));
|
||||
$xtpl->assign('TIME_MERIDIEM', $timedate->AMPMMenu('',$focus->time_start));
|
||||
|
||||
$parent_types = $app_list_strings['record_type_display'];
|
||||
$disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
|
||||
|
||||
foreach($disabled_parent_types as $disabled_parent_type){
|
||||
if($disabled_parent_type != $focus->parent_type){
|
||||
unset($parent_types[$disabled_parent_type]);
|
||||
}
|
||||
}
|
||||
|
||||
$xtpl->assign('TYPE_OPTIONS', get_select_options_with_id($parent_types, $focus->parent_type));
|
||||
$xtpl->assign('USER_DATEFORMAT', '('. $timedate->get_user_date_format().')');
|
||||
$xtpl->assign('PARENT_NAME', $focus->parent_name);
|
||||
$xtpl->assign('PARENT_ID', $focus->parent_id);
|
||||
if(empty($focus->parent_type)) {
|
||||
$xtpl->assign('PARENT_RECORD_TYPE', '');
|
||||
} else {
|
||||
$xtpl->assign('PARENT_RECORD_TYPE', $focus->parent_type);
|
||||
}
|
||||
|
||||
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
|
||||
$record = '';
|
||||
if(!empty($_REQUEST['record'])){
|
||||
$record = $_REQUEST['record'];
|
||||
}
|
||||
$xtpl->assign('ADMIN_EDIT',"<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
|
||||
}
|
||||
|
||||
//// END GENERAL TEMPLATE ASSIGNMENTS
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
///
|
||||
/// SETUP PARENT POPUP
|
||||
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'parent_id',
|
||||
'name' => 'parent_name',
|
||||
),
|
||||
);
|
||||
|
||||
$encoded_popup_request_data = $json->encode($popup_request_data);
|
||||
|
||||
/// Users Popup
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'assigned_user_id',
|
||||
'user_name' => 'assigned_user_name',
|
||||
),
|
||||
);
|
||||
$xtpl->assign('encoded_users_popup_request_data', $json->encode($popup_request_data));
|
||||
|
||||
|
||||
|
||||
$xtpl->assign('PRICEBOOK_ID', $_REQUEST['pricebook_id']);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
///////////////////////////////////////
|
||||
|
||||
$change_parent_button = '<input type="button" name="button" tabindex="2" class="button" '
|
||||
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
|
||||
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
|
||||
. 'value="' . $app_strings['LBL_SELECT_BUTTON_LABEL'] . '" '
|
||||
. "onclick='open_popup(document.EditView.parent_type.value,600,400,\"&tree=ProductsProd\",true,false,$encoded_popup_request_data);' />\n";
|
||||
$xtpl->assign("CHANGE_PARENT_BUTTON", $change_parent_button);
|
||||
|
||||
$button_attr = '';
|
||||
if(!ACLController::checkAccess('Contacts', 'list', true)){
|
||||
$button_attr = 'disabled="disabled"';
|
||||
}
|
||||
|
||||
$change_to_addrs_button = '<input type="button" name="to_button" tabindex="3" class="button" '
|
||||
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
|
||||
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
|
||||
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
|
||||
. "onclick='button_change_onclick(this);' $button_attr />\n";
|
||||
$xtpl->assign("CHANGE_TO_ADDRS_BUTTON", $change_to_addrs_button);
|
||||
|
||||
$change_cc_addrs_button = '<input type="button" name="cc_button" tabindex="3" class="button" '
|
||||
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
|
||||
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
|
||||
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
|
||||
. "onclick='button_change_onclick(this);' $button_attr />\n";
|
||||
$xtpl->assign("CHANGE_CC_ADDRS_BUTTON", $change_cc_addrs_button);
|
||||
|
||||
$change_bcc_addrs_button = '<input type="button" name="bcc_button" tabindex="3" class="button" '
|
||||
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
|
||||
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
|
||||
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
|
||||
. "onclick='button_change_onclick(this);' $button_attr />\n";
|
||||
$xtpl->assign("CHANGE_BCC_ADDRS_BUTTON", $change_bcc_addrs_button);
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
//// USER ASSIGNMENT
|
||||
global $current_user;
|
||||
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
|
||||
$record = '';
|
||||
if(!empty($_REQUEST['record'])) {
|
||||
$record = $_REQUEST['record'];
|
||||
}
|
||||
$xtpl->assign('ADMIN_EDIT',"<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
|
||||
}
|
||||
|
||||
if(empty($focus->assigned_user_id) && empty($focus->id))
|
||||
$focus->assigned_user_id = $current_user->id;
|
||||
if(empty($focus->assigned_name) && empty($focus->id))
|
||||
$focus->assigned_user_name = $current_user->user_name;
|
||||
$xtpl->assign('ASSIGNED_USER_OPTIONS', get_select_options_with_id(get_user_array(TRUE, 'Active', $focus->assigned_user_id), $focus->assigned_user_id));
|
||||
$xtpl->assign('ASSIGNED_USER_NAME', $focus->assigned_user_name);
|
||||
$xtpl->assign('ASSIGNED_USER_ID', $focus->assigned_user_id);
|
||||
$xtpl->assign('DURATION_HOURS', $focus->duration_hours);
|
||||
$xtpl->assign('TYPE_OPTIONS', get_select_options_with_id($parent_types, $focus->parent_type));
|
||||
$xtpl->assign("PIDFROM",$_REQUEST['pIdFrom']);
|
||||
$xtpl->assign("PTYPEFROM",$_REQUEST['pTypeFrom']);
|
||||
$xtpl->assign("PIDTO",$_REQUEST['pIdTo']);
|
||||
$xtpl->assign("PTYPETO",$_REQUEST['pTypeTo']);
|
||||
if(isset($focus->duration_minutes)) {
|
||||
$xtpl->assign('DURATION_MINUTES_OPTIONS', get_select_options_with_id($focus->minutes_values,$focus->duration_minutes));
|
||||
}
|
||||
//// END USER ASSIGNMENT
|
||||
///////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//Add Custom Fields
|
||||
require_once('modules/DynamicFields/templates/Files/EditView.php');
|
||||
require_once("modules/Notes/Note.php");
|
||||
|
||||
///////////////////////////////////////
|
||||
//// ATTACHMENTS
|
||||
$attachments = '';
|
||||
if(!empty($focus->id) || (!empty($_REQUEST['record']) && $_REQUEST['type'] == 'forward')) {
|
||||
|
||||
$attachments = "<input type='hidden' name='removeAttachment' id='removeAttachment' value=''>\n";
|
||||
$ids = '';
|
||||
|
||||
$focusId = empty($focus->id) ? $_REQUEST['record'] : $focus->id;
|
||||
$note = new Note();
|
||||
$where = "notes.parent_id='{$focusId}' AND notes.filename IS NOT NULL";
|
||||
$notes_list = $note->get_full_list("", $where,true);
|
||||
|
||||
if(!isset($notes_list)) {
|
||||
$notes_list = array();
|
||||
}
|
||||
for($i = 0;$i < count($notes_list);$i++) {
|
||||
$the_note = $notes_list[$i];
|
||||
if(empty($the_note->filename)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// cn: bug 8034 - attachments from forwards/replies lost when saving drafts
|
||||
if(!empty($ids)) {
|
||||
$ids .= ",";
|
||||
}
|
||||
$ids .= $the_note->id;
|
||||
|
||||
$attachments .= "
|
||||
<div id='noteDiv{$the_note->id}'>
|
||||
<img onclick='deletePriorAttachment(\"{$the_note->id}\");' src='themes/{$theme}/images/delete_inline.gif' value='{$the_note->id}'> ";
|
||||
$attachments .= '<a href="'.UploadFile::get_url($the_note->filename,$the_note->id).'" target="_blank">'. $the_note->filename .'</a></div>';
|
||||
|
||||
}
|
||||
// cn: bug 8034 - attachments from forwards/replies lost when saving drafts
|
||||
$attachments .= "<input type='hidden' name='prior_attachments' value='{$ids}'>";
|
||||
|
||||
// workaround $mod_strings being overriden by Note object instantiation above.
|
||||
global $current_language, $mod_strings;
|
||||
$mod_strings = return_module_language($current_language, 'Emails');
|
||||
}
|
||||
|
||||
$attJs = '<script type="text/javascript">';
|
||||
$attJs .= 'var file_path = "'.$sugar_config['site_url'].'/'.$sugar_config['upload_dir'].'";';
|
||||
$attJs .= 'var lnk_remove = "'.$app_strings['LNK_REMOVE'].'";';
|
||||
$attJs .= '</script>';
|
||||
$xtpl->assign('ATTACHMENTS', $attachments);
|
||||
$xtpl->assign('ATTACHMENTS_JAVASCRIPT', $attJs);
|
||||
//// END ATTACHMENTS
|
||||
///////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// DOCUMENTS
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'document_set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'related_doc_id',
|
||||
'document_name' => 'related_document_name',
|
||||
),
|
||||
);
|
||||
$json = getJSONobj();
|
||||
$xtpl->assign('encoded_document_popup_request_data', $json->encode($popup_request_data));
|
||||
//// END DOCUMENTS
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$parse_open = true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($parse_open) {
|
||||
$xtpl->parse('main.open_source_1');
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// EMAIL TEMPLATES
|
||||
if(ACLController::checkAccess('EmailTemplates', 'list', true) && ACLController::checkAccess('EmailTemplates', 'view', true)) {
|
||||
$et = new EmailTemplate();
|
||||
$etResult = $focus->db->query($et->create_list_query('','',''));
|
||||
$email_templates_arr[] = '';
|
||||
$toTemplateId = '';
|
||||
while($etA = $focus->db->fetchByAssoc($etResult)) {
|
||||
if($toTemplate == $etA['name']) { $toTemplateId = $etA['id']; }
|
||||
$email_templates_arr[$etA['id']] = $etA['name'];
|
||||
}
|
||||
} else {
|
||||
$email_templates_arr = array('' => $app_strings['LBL_NONE']);
|
||||
}
|
||||
|
||||
$xtpl->assign('EMAIL_TEMPLATE_OPTIONS', get_select_options_with_id($email_templates_arr, $toTemplateId));
|
||||
//// END EMAIL TEMPLATES
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////
|
||||
//// TEXT EDITOR
|
||||
// cascade from User to Sys Default
|
||||
$editor = $focus->getUserEditorPreference();
|
||||
|
||||
if($editor != 'plain') {
|
||||
// this box is checked by Javascript on-load.
|
||||
$xtpl->assign('EMAIL_EDITOR_OPTION', 'CHECKED');
|
||||
}
|
||||
$description_html = from_html($focus->description_html);
|
||||
$description = $focus->description;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// signatures
|
||||
if($sig = $current_user->getDefaultSignature()) {
|
||||
if(!$focus->hasSignatureInBody($sig) && $focus->type != 'draft') {
|
||||
if($current_user->getPreference('signature_prepend')) {
|
||||
$description_html = '<br />'.from_html($sig['signature_html']).'<br /><br />'.$description_html;
|
||||
$description = "\n".$sig['signature']."\n\n".$description;
|
||||
} else {
|
||||
$description_html .= '<br /><br />'.from_html($sig['signature_html']);
|
||||
$description = $description."\n\n".$sig['signature'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$xtpl->assign('DESCRIPTION', $description);
|
||||
// sigs
|
||||
/////////////////////////////////////////////////
|
||||
$tiny = new SugarTinyMCE();
|
||||
$ed = $tiny->getInstance("description_html");
|
||||
$xtpl->assign("TINY", $ed);
|
||||
$xtpl->assign("DESCRIPTION_HTML", $description_html);
|
||||
|
||||
if((!isset($_REQUEST['record']) || $_REQUEST['record'] == '') && isset($toTemplateId) && $toTemplateId != "") {
|
||||
require_once('modules/EmailTemplates/EmailTemplate.php');
|
||||
$et = new EmailTemplate();
|
||||
$et->retrieve($toTemplateId);
|
||||
if(isset($et->id) && $et->id != '') {
|
||||
$xtpl->assign("NAME",$et->subject);
|
||||
$xtpl->assign("DESCRIPTION",$et->body);
|
||||
$xtpl->assign("DESCRIPTION_HTML",$et->body_html);
|
||||
}
|
||||
}
|
||||
|
||||
$xtpl->parse('main.htmlarea');
|
||||
//// END TEXT EDITOR
|
||||
///////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////
|
||||
//// SPECIAL INBOUND LANDING SCREEN ASSIGNS
|
||||
if(!empty($_REQUEST['inbound_email_id'])) {
|
||||
if(!empty($_REQUEST['start'])) {
|
||||
$parts = $focus->getStartPage(base64_decode($_REQUEST['start']));
|
||||
$xtpl->assign('RETURN_ACTION', $parts['action']);
|
||||
$xtpl->assign('RETURN_MODULE', $parts['module']);
|
||||
$xtpl->assign('GROUP', $parts['group']);
|
||||
}
|
||||
$xtpl->assign('ASSIGNED_USER_ID', $current_user->id);
|
||||
$xtpl->assign('MYINBOX', 'this.form.type.value=\'inbound\';');
|
||||
}
|
||||
//// END SPECIAL INBOUND LANDING SCREEN ASSIGNS
|
||||
///////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo '<script>var disabledModules='. $json->encode($disabled_parent_types) . ';</script>';
|
||||
$jsVars = 'var lbl_send_anyways = "'.$mod_strings['LBL_SEND_ANYWAYS'].'";';
|
||||
$xtpl->assign('JS_VARS', $jsVars);
|
||||
$xtpl->parse("main");
|
||||
$xtpl->out("main");
|
||||
echo '<script>checkParentType(document.EditView.parent_type.value, document.EditView.change_parent);</script>';
|
||||
//// END XTEMPLATE ASSIGNMENT
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once('include/javascript/javascript.php');
|
||||
$javascript = new javascript();
|
||||
$javascript->setFormName('email_EditView');
|
||||
$javascript->setSugarBean($focus);
|
||||
$skip_fields = array();
|
||||
if($email_type == 'out') {
|
||||
$skip_fields['name'] = 1;
|
||||
$skip_fields['date_start'] = 1;
|
||||
}
|
||||
$javascript->addAllFields('',$skip_fields);
|
||||
$javascript->addToValidateBinaryDependency('parent_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id');
|
||||
$javascript->addToValidateBinaryDependency('parent_type', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id');
|
||||
|
||||
|
||||
|
||||
|
||||
$javascript->addToValidateBinaryDependency('user_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ASSIGNED_TO'], 'false', '', 'assigned_user_id');
|
||||
if($email_type == 'archived') {
|
||||
$javascript->addFieldIsValidDate('date_start', 'date', $mod_strings['LBL_DATE'], $mod_strings['ERR_DATE_START'], true);
|
||||
$javascript->addFieldIsValidTime('time_start', 'time', $mod_strings['LBL_TIME'], $mod_strings['ERR_TIME_START'], true);
|
||||
}
|
||||
echo $javascript->getScript();
|
||||
111
modules/EcmPriceBooks2/Forms.php
Executable file
111
modules/EcmPriceBooks2/Forms.php
Executable file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* CREATE JAVASCRIPT TO VALIDATE THE DATA ENTERED INTO A RECORD.
|
||||
*******************************************************************************/
|
||||
function get_validate_record_js () {
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* CREATE FORM FOR MENU RAPID CREATE
|
||||
*******************************************************************************/
|
||||
function get_new_record_form () {
|
||||
if(!ACLController::checkAccess('EcmPriceBooks', 'edit', true)){
|
||||
return '';
|
||||
}
|
||||
global $mod_strings;
|
||||
global $app_strings;
|
||||
global $app_list_strings;
|
||||
global $mod_strings;
|
||||
global $theme;
|
||||
global $current_user;
|
||||
|
||||
$lbl_subject = $mod_strings['LBL_SUBJECT'];
|
||||
$lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
|
||||
$lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE'];
|
||||
$lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY'];
|
||||
$lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL'];
|
||||
$user_id = $current_user->id;
|
||||
|
||||
|
||||
$the_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
|
||||
$the_form .= <<<EOQ
|
||||
|
||||
<form name="EcmPriceBookSave" onSubmit="return check_form('EcmPriceBooksSave')" method="POST" action="index.php">
|
||||
<input type="hidden" name="module" value="EcmPriceBooks">
|
||||
<input type="hidden" name="record" value="">
|
||||
<input type="hidden" name="assigned_user_id" value='${user_id}'>
|
||||
<input type="hidden" name="action" value="Save">
|
||||
|
||||
${lbl_subject} <span class="required">${lbl_required_symbol}</span><br>
|
||||
<p><input name='name' type="text" size='20' maxlength="255"value=""><br>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input title="${lbl_save_button_title}" accessKey="${lbl_save_button_key}" class="button" type="submit" name="button" value=" ${lbl_save_button_label} " >
|
||||
</p>
|
||||
|
||||
</form>
|
||||
EOQ;
|
||||
require_once('include/javascript/javascript.php');
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
$javascript = new javascript();
|
||||
$javascript->setFormName('EcmPriceBooksSave}');
|
||||
$javascript->setSugarBean(new EcmPriceBook());
|
||||
$javascript->addRequiredFields('');
|
||||
$the_form .= $javascript->getScript();
|
||||
$the_form .= get_left_form_footer();
|
||||
|
||||
return $the_form;
|
||||
}
|
||||
|
||||
?>
|
||||
148
modules/EcmPriceBooks2/ListHelper.php
Executable file
148
modules/EcmPriceBooks2/ListHelper.php
Executable file
@@ -0,0 +1,148 @@
|
||||
<?
|
||||
function dy($text) {
|
||||
$text=str_replace("ą","1",$text);
|
||||
$text=str_replace("ć","a",$text);
|
||||
$text=str_replace("ę","e",$text);
|
||||
$text=str_replace("A<EFBFBD>","3",$text);
|
||||
$text=str_replace("A<EFBFBD>","n",$text);
|
||||
$text=str_replace("A3","<EFBFBD>",$text);
|
||||
$text=str_replace("A<EFBFBD>","o",$text);
|
||||
$text=str_replace("A1","?",$text);
|
||||
$text=str_replace("Ao","Y",$text);
|
||||
$text=str_replace("Ą","Y",$text);
|
||||
$text=str_replace("Ć","A",$text);
|
||||
$text=str_replace("<EFBFBD>~","E",$text);
|
||||
$text=str_replace("A<EFBFBD>","L",$text);
|
||||
$text=str_replace("Af","N",$text);
|
||||
$text=str_replace("A<EFBFBD>","<EFBFBD>",$text);
|
||||
$text=str_replace("A<EFBFBD>","O",$text);
|
||||
$text=str_replace("A<EFBFBD>","<EFBFBD>",$text);
|
||||
$text=str_replace("A1","?",$text);
|
||||
return plc($text);
|
||||
}
|
||||
function plc($string, $type = UTF8_TO_WIN1250)
|
||||
{
|
||||
$win2utf = array(
|
||||
"\xb9" => "\xc4\x85", "\xa5" => "\xc4\x84",
|
||||
"\xe6" => "\xc4\x87", "\xc6" => "\xc4\x86",
|
||||
"\xea" => "\xc4\x99", "\xca" => "\xc4\x98",
|
||||
"\xb3" => "\xc5\x82", "\xa3" => "\xc5\x81",
|
||||
"\xf3" => "\xc3\xb3", "\xd3" => "\xc3\x93",
|
||||
"\x9c" => "\xc5\x9b", "\x8c" => "\xc5\x9a",
|
||||
"\xbf" => "\xc5\xbc", "\x8f" => "\xc5\xbb",
|
||||
"\x9f" => "\xc5\xba", "\xaf" => "\xc5\xb9",
|
||||
"\xf1" => "\xc5\x84", "\xd1" => "\xc5\x83"
|
||||
);
|
||||
$iso2utf = array(
|
||||
"\xb1" => "\xc4\x85", "\xa1" => "\xc4\x84",
|
||||
"\xe6" => "\xc4\x87", "\xc6" => "\xc4\x86",
|
||||
"\xea" => "\xc4\x99", "\xca" => "\xc4\x98",
|
||||
"\xb3" => "\xc5\x82", "\xa3" => "\xc5\x81",
|
||||
"\xf3" => "\xc3\xb3", "\xd3" => "\xc3\x93",
|
||||
"\xb6" => "\xc5\x9b", "\xa6" => "\xc5\x9a",
|
||||
"\xbc" => "\xc5\xba", "\xac" => "\xc5\xb9",
|
||||
"\xbf" => "\xc5\xbc", "\xaf" => "\xc5\xbb",
|
||||
"\xf1" => "\xc5\x84", "\xd1" => "\xc5\x83"
|
||||
);
|
||||
|
||||
if ($type == ISO88592_TO_UTF8)
|
||||
return strtr($string, $iso2utf);
|
||||
if ($type == UTF8_TO_ISO88592)
|
||||
return strtr($string, array_flip($iso2utf));
|
||||
if ($type == WIN1250_TO_UTF8)
|
||||
return strtr($string, $win2utf);
|
||||
if ($type == UTF8_TO_WIN1250)
|
||||
return strtr($string, array_flip($win2utf));
|
||||
if ($type == ISO88592_TO_WIN1250)
|
||||
return strtr($string, "\xa1\xa6\xac\xb1\xb6\xbc",
|
||||
"\xa5\x8c\x8f\xb9\x9c\x9f");
|
||||
if ($type == WIN1250_TO_ISO88592)
|
||||
return strtr($string, "\xa5\x8c\x8f\xb9\x9c\x9f",
|
||||
"\xa1\xa6\xac\xb1\xb6\xbc");
|
||||
}
|
||||
function imgType($name){
|
||||
if(substr($name, -4, 4) == '.jpg' || substr($name, -4, 4) == 'jpeg')return "IMAGETYPE_JPEG";
|
||||
elseif(substr($name, -4, 4) == '.gif')return "IMAGETYPE_GIF";
|
||||
elseif(substr($name, -4, 4) == '.png') return "IMAGETYPE_PNG";
|
||||
}
|
||||
|
||||
function resizeImage($source, $max_x, $max_y, $save_image, $jpeg_quality = 100){
|
||||
if(imgType($source) == "IMAGETYPE_JPEG")$img_src = imagecreatefromjpeg($source);
|
||||
elseif(imgType($source) == "IMAGETYPE_GIF")$img_src = imagecreatefromgif($source);
|
||||
elseif(imgType($source) == "IMAGETYPE_PNG")$img_src = imagecreatefrompng($source);
|
||||
else die('Wrong filetype! Accepted images: JPG/JPEG, GIF, PNG');
|
||||
|
||||
$image_x = imagesx($img_src);
|
||||
$image_y = imagesy($img_src);
|
||||
if($image_x > $image_y){
|
||||
$ratio_x = ($image_x > $max_x) ? $max_x/$image_x : 1;
|
||||
$ratio_y = $ratio_x;
|
||||
$move = 'y';
|
||||
}
|
||||
else{
|
||||
$ratio_y = ($image_y > $max_y) ? $max_y/$image_y : 1;
|
||||
$ratio_x = $ratio_y;
|
||||
$move = 'x';
|
||||
}
|
||||
$new_x = $image_x*$ratio_x;
|
||||
$new_y = $image_y*$ratio_y;
|
||||
|
||||
$move_x = ($move == "x") ? ($max_x-$new_x)/2 : 0;
|
||||
$move_y = ($move == "y") ? ($max_y-$new_y)/2 : 0;
|
||||
|
||||
$new_img = imagecreatetruecolor($max_x, $max_y);
|
||||
$background = imagecolorallocate($new_img, 255, 255, 255);
|
||||
$black = imagecolorallocate($new_img,0,0,0);
|
||||
imagefill($new_img, 0, 0, $background);
|
||||
imagecopyresampled($new_img, $img_src, $move_x, $move_y, 0, 0, $new_x, $new_y, $image_x, $image_y);
|
||||
|
||||
$ix=ceil($max_x/90);
|
||||
$iy=ceil($max_y/90);
|
||||
for($i=0;$i<$ix;$i++)imageline($new_img,$i,0,$i,$max_y,$background);
|
||||
for($i=0;$i<$iy;$i++)imageline($new_img,0,$i,$max_x,$i,$background);
|
||||
for($i=0;$i<$ix;$i++)imageline($new_img,$max_x-$i,0,$max_x-$i,$max_y,$background);
|
||||
for($i=0;$i<$iy;$i++)imageline($new_img,0,$max_y-$i,$max_x,$max_y-$i,$background);
|
||||
|
||||
if(imgType($save_image) == "IMAGETYPE_JPEG")imagejpeg($new_img, $save_image,100);
|
||||
elseif(imgType($save_image) == "IMAGETYPE_GIF")imagegif($new_img, $save_image,100);
|
||||
elseif(imgType($save_image) == "IMAGETYPE_PNG") imagepng($new_img, $save_image,100);
|
||||
}
|
||||
function addExchangeRateValue($value,$field,$er,$n=false)
|
||||
{
|
||||
$tabs=array("fob_price","purchase_price","ems_price","srp_price","srp_promo_price","price","list_price");
|
||||
foreach($tabs as $tab)
|
||||
{
|
||||
if($tab==$field)
|
||||
{
|
||||
if(!$n)$value=number_format($value/$er,2,",",".");
|
||||
else $value=$value/$er;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function sortLink($order_by,$sorder,$title)
|
||||
{
|
||||
if($order_by==$_REQUEST['order_by'])
|
||||
{
|
||||
if($sorder=="desc")
|
||||
{
|
||||
$img='<img border="0" src="themes/Sugar/images/arrow_down.gif" width="8" height="10" align="absmiddle" alt="">';
|
||||
$s="asc";
|
||||
}
|
||||
else
|
||||
{
|
||||
$img='<img border="0" src="themes/Sugar/images/arrow_up.gif" width="8" height="10" align="absmiddle" alt="">';
|
||||
$s="desc";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$img='<img border="0" src="themes/Sugar/images/arrow.gif" width="8" height="10" align="absmiddle" alt="">';
|
||||
$s=$sorder;
|
||||
}
|
||||
|
||||
return '<a style="cursor:pointer;" onclick="mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=ListViewProductsAjax&customview_id='.$_GET['customview_id'].'&pricebook_id='.$_REQUEST['pricebook_id'].'&order_by='.$order_by.'&sorder='.$s.'\',\'products\');">'.$title.' '.$img.'</a>';
|
||||
}
|
||||
?>
|
||||
51
modules/EcmPriceBooks2/ListView.php
Executable file
51
modules/EcmPriceBooks2/ListView.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings;
|
||||
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once('modules/EcmPriceBooks/Forms.php');
|
||||
require_once ('include/time.php');
|
||||
require_once('include/json_config.php');
|
||||
|
||||
$json_config = new json_config();
|
||||
|
||||
$focus = new EcmPriceBook();
|
||||
|
||||
if(isset($_REQUEST['record'])) {
|
||||
$focus->retrieve($_REQUEST['record']);
|
||||
}
|
||||
else {}
|
||||
|
||||
require_once('include/MVC/View/SugarView.php');
|
||||
|
||||
if(file_exists('modules/EcmPriceBooks/views/view.list.php')) {
|
||||
require_once('modules/EcmPriceBooks/views/view.list.php');
|
||||
$list = new EcmPriceBooksViewList();
|
||||
}
|
||||
else {
|
||||
require_once('include/MVC/View/views/view.list.php');
|
||||
$list = new ViewList();
|
||||
}
|
||||
|
||||
$list->bean = $focus;
|
||||
|
||||
// if(!isset($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] != "true") require_once('modules/EcmGroupSales/HeaderMenu.php');
|
||||
|
||||
|
||||
//$_REQUEST['query']="true";
|
||||
//$_REQUEST['clear_query']="true";
|
||||
if(!$_REQUEST['query'] && !$_REQUEST['clear_query']){
|
||||
$_REQUEST['archived_basic']="0";
|
||||
$_REQUEST['archived']="0";
|
||||
}
|
||||
elseif($_REQUEST['query'] && $_REQUEST['clear_query']){
|
||||
$_REQUEST['archived_basic']="0";
|
||||
$_REQUEST['archived']="0";
|
||||
}
|
||||
//print_r($_REQUEST);
|
||||
$list->preDisplay();
|
||||
$list->display();
|
||||
|
||||
?>
|
||||
196
modules/EcmPriceBooks2/ListViewAdd.php
Executable file
196
modules/EcmPriceBooks2/ListViewAdd.php
Executable file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
require_once ('XTemplate/xtpl.php');
|
||||
require_once ("data/Tracker.php");
|
||||
require_once ('modules/EcmProducts/EcmProduct.php');
|
||||
require_once ('themes/'.$theme.'/layout_utils.php');
|
||||
require_once ('log4php/LoggerManager.php');
|
||||
require_once('include/ListView/ListViewSmarty.php');
|
||||
require_once('include/ListView/ListView.php');
|
||||
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
|
||||
if(file_exists('custom/modules/EcmProducts/metadata/listviewdefs.php')){
|
||||
require_once('custom/modules/EcmProducts/metadata/listviewdefs.php');
|
||||
}else{
|
||||
require_once('modules/EcmProducts/metadata/listviewdefs.php');
|
||||
}
|
||||
require_once('modules/SavedSearch/SavedSearch.php');
|
||||
require_once('include/SearchForm/SearchForm.php');
|
||||
|
||||
$header_text = '';
|
||||
|
||||
global $app_strings;
|
||||
global $mod_strings;
|
||||
global $app_list_strings;
|
||||
global $current_language;
|
||||
$current_module_strings = return_module_language($current_language, 'EcmProducts');
|
||||
|
||||
global $urlPrefix;
|
||||
global $currentModule;
|
||||
|
||||
global $theme;
|
||||
global $current_user;
|
||||
// FOCUS_LIST IS THE MEANS OF PASSING DATA TO A LISTVIEW.
|
||||
global $focus_list;
|
||||
|
||||
// SETUP QUICKSEARCH
|
||||
require_once('include/QuickSearchDefaults.php');
|
||||
$qsd = new QuickSearchDefaults();
|
||||
|
||||
// CLEAR THE DISPLAY COLUMNS BACK TO DEFAULT WHEN CLEAR QUERY IS CALLED
|
||||
if(!empty($_REQUEST['clear_query']) && $_REQUEST['clear_query'] == 'true')
|
||||
$current_user->setPreference('ListViewDisplayColumns', array(), 0, $currentModule);
|
||||
|
||||
$savedDisplayColumns = $current_user->getPreference('ListViewDisplayColumns', $currentModule); // GET USER DEFINED DISPLAY COLUMNS
|
||||
|
||||
$json = getJSONobj();
|
||||
|
||||
$seedEcmProduct = new EcmProduct(); // SEED BEAN
|
||||
$searchForm = new SearchForm('EcmProducts', $seedEcmProduct); // NEW SEARCHFORM INSTANCE
|
||||
// SETUP LISTVIEW SMARTY
|
||||
$lv = new ListViewSmarty();
|
||||
|
||||
$displayColumns = array();
|
||||
// CHECK $_REQUEST IF NEW DISPLAY COLUMNS FROM POST
|
||||
if (!empty($_REQUEST['displayColumns'])) {
|
||||
foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) {
|
||||
if (!empty($listViewDefs['EcmProducts'][$col]))
|
||||
$displayColumns[$col] = $listViewDefs['EcmProducts'][$col];
|
||||
}
|
||||
}elseif(!empty($savedDisplayColumns)) { // USE USER DEFINED DISPLAY COLUMNS FROM PREFERENCES
|
||||
$displayColumns = $savedDisplayColumns;
|
||||
}else { // USE COLUMNS DEFINED IN LISTVIEWDEFS FOR DEFAULT DISPLAY COLUMNS
|
||||
foreach($listViewDefs['EcmProducts'] as $col => $params) {
|
||||
if(!empty($params['default']) && $params['default'])
|
||||
$displayColumns[$col] = $params;
|
||||
}
|
||||
}
|
||||
$params = array('massupdate' => true); // SETUP LISTVIEWSMARTY PARAMS
|
||||
if(!empty($_REQUEST['orderBy'])) { // ORDER BY COMING FROM $_REQUEST
|
||||
$params['orderBy'] = $_REQUEST['orderBy'];
|
||||
$params['overrideOrder'] = true;
|
||||
if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
|
||||
}
|
||||
$lv->displayColumns = $displayColumns;
|
||||
if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only']) { // HANDLE AJAX REQUESTS FOR SEARCH FORMS ONLY
|
||||
switch($_REQUEST['search_form_view']) {
|
||||
case 'basic_search':
|
||||
$searchForm->setup();
|
||||
$searchForm->displayBasic(false);
|
||||
break;
|
||||
case 'advanced_search':
|
||||
$searchForm->setup();
|
||||
$searchForm->displayAdvanced(false);
|
||||
break;
|
||||
case 'saved_views':
|
||||
echo $searchForm->displaySavedViews($listViewDefs, $lv, false);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// USE THE STORED QUERY IF THERE IS ONE
|
||||
if (!isset($where)) $where = "";
|
||||
require_once('modules/MySettings/StoreQuery.php');
|
||||
$storeQuery = new StoreQuery();
|
||||
|
||||
if(!isset($_REQUEST['query'])){
|
||||
$storeQuery->loadQuery($currentModule);
|
||||
$storeQuery->populateRequest();
|
||||
}else{
|
||||
$storeQuery->saveFromGet($currentModule);
|
||||
}
|
||||
if(isset($_REQUEST['query'])){
|
||||
// WE HAVE A QUERY
|
||||
// FIRST SAVE COLUMNS
|
||||
$current_user->setPreference('ListViewDisplayColumns', $displayColumns, 0, $currentModule);
|
||||
$searchForm->populateFromRequest(); // GATHERS SEARCH FIELD INPUTS FROM $_REQUEST
|
||||
$where_clauses = $searchForm->generateSearchWhere(true, "EcmProduct"); // BUILDS THE WHERE CLAUSE FROM SEARCH FIELD INPUTS
|
||||
if (count($where_clauses) > 0 )$where = implode(' and ', $where_clauses);
|
||||
$GLOBALS['log']->info("Here is the where clause for the list view: $where");
|
||||
}
|
||||
|
||||
// START DISPLAY
|
||||
// WHICH TAB OF SEARCH FORM TO DISPLAY
|
||||
if(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
|
||||
$searchForm->setup();
|
||||
if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
|
||||
$searchForm->displayAdvanced();
|
||||
}elseif(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'saved_views'){
|
||||
$searchForm->displaySavedViews($listViewDefs, $lv);
|
||||
}else {
|
||||
$searchForm->displayBasic();
|
||||
}
|
||||
}
|
||||
echo $qsd->GetQSScripts();
|
||||
/*
|
||||
$lv->setup($seedEcmProduct, 'include/ListView/ListViewGeneric.tpl', $where, $params);
|
||||
$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
|
||||
echo get_form_header($current_module_strings['LBL_LIST_FORM_TITLE'] . $savedSearchName, '', false);
|
||||
echo $lv->display();
|
||||
*/
|
||||
$ListView = new ListView();
|
||||
$ListView->initNewXTemplate('modules/EcmProducts/ListView1.html',$current_module_strings);
|
||||
$ListView->setHeaderTitle($current_module_strings['LBL_LIST_FORM_TITLE']);
|
||||
$ListView->setQuery($where, "", "name asc", "ECMPRODUCT");
|
||||
$ListView->processListView($seedEcmProduct, "main", "ECMPRODUCT");
|
||||
$savedSearch = new SavedSearch();
|
||||
$json = getJSONobj();
|
||||
// FILLS IN SAVED VIEWS SELECT BOX ON SHORTCUT MENU
|
||||
$savedSearchSelects = $json->encode(array($GLOBALS['app_strings']['LBL_SAVED_SEARCH_SHORTCUT'] . '<br>' . $savedSearch->getSelect('EcmProducts')));
|
||||
$str = "<script>
|
||||
YAHOO.util.Event.addListener(window, 'load', SUGAR.util.fillShortcuts, $savedSearchSelects);
|
||||
</script>";
|
||||
echo '<input type="hidden" name="pricebook_id" value="'.$_REQUEST['pricebook_id'].'">';
|
||||
echo '</form>';
|
||||
echo $str;
|
||||
?>
|
||||
54
modules/EcmPriceBooks2/ListViewAddToPriceBook.php
Executable file
54
modules/EcmPriceBooks2/ListViewAddToPriceBook.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?
|
||||
echo "\n<p>\n";
|
||||
echo get_module_title($mod_strings['LBL_MODULE_ID'], $mod_strings['LBL_MODULE_TITLE'], true);
|
||||
echo "\n</p>\n";
|
||||
?>
|
||||
<script language="javascript" src="modules/EcmProducts/helper.js"></script>
|
||||
<ul class="tablist">
|
||||
<li class="active"><a class="current" href="#">Basic Search</a></li>
|
||||
</ul>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td valign="top" noWrap class="dataLabel"> </td>
|
||||
<td valign="top" class="dataField"> </td>
|
||||
<td valign="top" class="dataLabel"> </td>
|
||||
<td valign="top" class="dataField"> </td>
|
||||
<td valign="top" class="dataLabel"> </td>
|
||||
<td valign="top" class="dataField"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="10%" valign="top" noWrap class="dataLabel">
|
||||
<span sugar='slot1'><? print $mod_strings['LBL_NAME'];?></span sugar='slot'></td>
|
||||
<td width="20%" valign="top" class="dataField">
|
||||
<span sugar='slot1b'>
|
||||
<input type=text name="name" id="name" class=dataField value="" />
|
||||
</span sugar='slot'> </td>
|
||||
<td width="10%" valign="top" class="dataLabel"><span sugar='slot2'><? print $mod_strings['LBL_INDEX'];?></span sugar='slot'></td>
|
||||
<td width="20%" valign="top" class="dataField"><input name='code' id='code' type="text" tabindex='2' title="Code" value="" maxlength='40' /></td>
|
||||
<td width="15%" valign="top" class="dataLabel"><? print $mod_strings['LBL_UNIT_PRICE'];?> </td>
|
||||
<td width="15%" valign="top" class="dataField"><input name='unit_price' id='unit_price' type="text" tabindex='2' value="" maxlength='40' /></td>
|
||||
</tr>
|
||||
<tr><td width="10%" valign="top" class="dataLabel"><? print $mod_strings['LBL_MANUFACTURER'];?></td>
|
||||
<td width="20%" valign="top" class="dataField"><select style="width:121px;" name="manufacturer" id="manufacturer"><option value=""><? print $mod_strings['LBL_ALL'];?></option><?
|
||||
$w=$GLOBALS['db']->query("select name,id from ecmproductmanufacturers order by name asc");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w))
|
||||
{
|
||||
print '<option value="'.$r['id'].'">'.$r['name'].'</option>';
|
||||
}
|
||||
?></select></td>
|
||||
<td width="20%" valign="top" class="dataLabel"><? print $mod_strings['LBL_PRODUCT_CATEGORY'];?></td>
|
||||
<td width="20%" valign="top" class="dataField"><select style="width:121px;" name="product_category" id="product_category"><option value=""><? print $mod_strings['LBL_ALL'];?></option><?
|
||||
$w=$GLOBALS['db']->query("select name,id from ecmproductcategories order by name asc");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w))
|
||||
{
|
||||
print '<option value="'.$r['id'].'">'.$r['name'].'</option>';
|
||||
}
|
||||
?></select></td>
|
||||
<td width="10%" valign="top" class="dataLabel"><input class="button" name="search" type="button" id="search" value="Search" onclick="mintajaxget('index.php?to_pdf=1&pricebook_id=<?print $_REQUEST['pricebook_id'];?>&module=EcmPriceBooks&action=ListViewAddToPriceBookAjax&name='+document.getElementById('name').value+'&unit_price='+document.getElementById('unit_price').value+'&code='+document.getElementById('code').value+'&product_category='+document.getElementById('product_category').value+'&manufacturer='+document.getElementById('manufacturer').value,'list');"></td>
|
||||
<td width="20%" valign="top" class="dataField"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
</table>
|
||||
|
||||
<div id="list"></div>
|
||||
<script language="javascript">mintajaxget('index.php?to_pdf=1&pricebook_id=<?print $_REQUEST['pricebook_id'];?>&module=EcmPriceBooks&action=ListViewAddToPriceBookAjax','list');</script>
|
||||
86
modules/EcmPriceBooks2/ListViewAddToPriceBookAjax.php
Executable file
86
modules/EcmPriceBooks2/ListViewAddToPriceBookAjax.php
Executable file
@@ -0,0 +1,86 @@
|
||||
<?
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
$_COOKIE['pricebook_id']=$_REQUEST['pricebook_id'];
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,id from ecmpricebooks where id='".$_REQUEST['pricebook_id']."'"));
|
||||
$pricebook_name=$r['name'];
|
||||
$pricebook_id=$r['id'];
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
$t=array(" ",$mod_strings['LBL_PRODUCT_NAME'],$mod_strings['LBL_INDEX'],$mod_strings['LBL_PRICEBOOK_NAME'], $mod_strings['LBL_UNIT_PRICE'],$mod_strings['LBL_MARGIN'],$mod_strings['LBL_LIST_PRICE_ADD']);
|
||||
|
||||
$sorder=$_REQUEST['sorder'];
|
||||
print '<script language="javascript" src="modules/EcmProducts/helper.js"></script>';
|
||||
|
||||
print '<form name="AddToPriceBook" method="post" action="index.php">';
|
||||
print '<input type="hidden" name="to_pdf" value="1">';
|
||||
print '<input type="hidden" name="module" value="EcmPriceBooks">';
|
||||
print '<input type="hidden" name="action" value="AddToPriceBook">';
|
||||
print '<input type="hidden" name="pricebook_id" value="'.$_REQUEST['pricebook_id'].'">';
|
||||
print '<input class="button" type="submit" value="Update"><br><br>';
|
||||
print '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="ListView"><tr>';
|
||||
for($i=0;$i<count($t);$i++)
|
||||
{
|
||||
print '<td class="listViewThS1">'.$t[$i].'</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
if($_REQUEST['name'])$arr[]="ecmproducts.name like '%".$_REQUEST['name']."%'";
|
||||
if($_REQUEST['code'])$arr[]="ecmproducts.code like '%".$_REQUEST['code']."%'";
|
||||
if($_REQUEST['purchase_price'])$arr[]="ecmproducts.purchase_price='".$_REQUEST['purchase_price']."'";
|
||||
if($_REQUEST['product_category'])$arr[]="ecmproducts.product_category_id='".$_REQUEST['product_category']."'";
|
||||
if($_REQUEST['manufacturer'])$arr[]="ecmproducts.manufacturer_id='".$_REQUEST['manufacturer']."'";
|
||||
$arr[]="ecmproducts.deleted='0'";
|
||||
|
||||
$w=$GLOBALS['db']->query("select ecmproduct_id from ecmpricebooks_ecmproducts where deleted='0' and ecmpricebook_id='".$_REQUEST['pricebook_id']."'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w))$arr[]="ecmproducts.id!='".$r['ecmproduct_id']."'";
|
||||
|
||||
$where=implode(" and ",$arr);
|
||||
$z="select ecmproducts.name as name,ecmproducts.code as code,ecmproducts.id as id,ecmproducts.purchase_price as purchase_price from ecmproducts where ".$where." order by ecmproducts.name";
|
||||
//print $z;
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
|
||||
|
||||
print mysql_error();
|
||||
$i=0;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result))
|
||||
{
|
||||
print '<tr>';
|
||||
print '<input type="hidden" name="product_id['.$i.']" value="'.$row['id'].'">';
|
||||
|
||||
print '<td class="oddListRowS1" width="1%"><input onclick="getPrice(\''.$row['id'].'\',\'up\');ShowHideBlock(\'price_block2_'.$row['id'].'\');ShowHideBlock(\'price_block3_'.$row['id'].'\');" type="checkbox" name="check['.$i.']" value="'.$row['id'].'"></td>';
|
||||
|
||||
print '<td class="oddListRowS1"><a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">'.$row['name'].'</a></td>';
|
||||
print '<td class="oddListRowS1">'.$row['code'].'</td>';
|
||||
print '<td class="oddListRowS1"><a href="index.php?module=EcmPriceBooks&action=DetailView&record='.$pricebook_id.'">'.$pricebook_name.'</a></td>';
|
||||
print '<td class="oddListRowS1">'.number_format($row['purchase_price'],2,",",".").'</td>';
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select price from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_REQUEST['pricebook_id']."' and ecmproduct_id='".$row['id']."'"));
|
||||
|
||||
//print '<td class="oddListRowS1">'.number_format($r['price'],2,",",".").'</td>';
|
||||
|
||||
print '
|
||||
<div id="price_block1_'.$row['id'].'" style="display:none;">
|
||||
<input onchange="getPrice(\''.$row['id'].'\',\'down\');" onclick="getPrice(\''.$row['id'].'\',\'up\');" name="purchase_price_'.$row['id'].'" type="hidden" id="purchase_price_'.$row['id'].'" value="'.$row['purchase_price'].'" size="5" />
|
||||
</div>
|
||||
';
|
||||
print '<td>
|
||||
<div id="price_block2_'.$row['id'].'" style="display:none;">
|
||||
<input onchange="getPrice(\''.$row['id'].'\',\'down\');" onclick="getPrice(\''.$row['id'].'\',\'up\');" name="margin_rate_'.$row['id'].'" type="text" id="margin_rate_'.$row['id'].'" value="20" size="2" />
|
||||
</td>
|
||||
<td>
|
||||
<div id="price_block3_'.$row['id'].'" style="display:none;">
|
||||
<input onchange="getPrice(\''.$row['id'].'\',\'down\');" onclick="getPrice(\''.$row['id'].'\',\'up\');" name="list_price_'.$row['id'].'" type="text" id="list_price_'.$row['id'].'" value="" size="6" />
|
||||
<script>getPrice(\''.$row['id'].'\',\'up\');</script>
|
||||
</div>
|
||||
</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
print '<br><input class="button" type="submit" value="'.$mod_strings['LBL_UPDATE'].'">';
|
||||
print '</form>';
|
||||
|
||||
?>
|
||||
73
modules/EcmPriceBooks2/ListViewPriceBooksAddToChangeOn.php
Executable file
73
modules/EcmPriceBooks2/ListViewPriceBooksAddToChangeOn.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<?
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
|
||||
echo "\n<p>\n";
|
||||
echo get_module_title($mod_strings['LBL_MODULE_ID'], $mod_strings['LBL_MODULE_TITLE'], true);
|
||||
echo "\n</p>\n";
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select id,name,purchase_price from ecmproducts where id='".$_REQUEST['product_id']."'"));
|
||||
$product_name=$r['name'];
|
||||
$product_id=$r['id'];
|
||||
$purchase_price=$r['purchase_price'];
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmproductexchangerates where id='".$exchange_rate_id."'"));
|
||||
$er_value=$r['value'];
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_REQUEST['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$t=array(" ",$mod_strings['LBL_PRODUCT_NAME'],$mod_strings['LBL_PRICEBOOK_NAME'],$mod_strings['LBL_PURCHASE_PRICE'],$mod_strings['LBL_LIST_PRICE'], " ");
|
||||
|
||||
$sorder=$_REQUEST['sorder'];
|
||||
print '<script language="javascript" src="modules/EcmProducts/helper.js"></script>';
|
||||
print '<form name="UpdatePriceBook" method="post" action="index.php">';
|
||||
print '<input type="hidden" name="to_pdf" value="1">';
|
||||
print '<input type="hidden" name="module" value="EcmPriceBooks">';
|
||||
print '<input type="hidden" name="action" value="UpdatePriceBook">';
|
||||
print '<input type="hidden" name="product_id" value="'.$_REQUEST['product_id'].'">';
|
||||
print '<input type="hidden" name="return_id" value="'.$_REQUEST['return_id'].'">';
|
||||
print '<input type="hidden" name="return_module" value="'.$_REQUEST['return_module'].'">';
|
||||
print '<input type="hidden" name="return_action" value="'.$_REQUEST['return_action'].'">';
|
||||
print '<input class="button" type="submit" value="'.$mod_strings['LBL_UPDATE'].'"><br><br>';
|
||||
print '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="ListView"><tr>';
|
||||
for($i=0;$i<count($t);$i++)
|
||||
{
|
||||
print '<td class="listViewThS1">'.$t[$i].'</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
$result = $GLOBALS['db']->query("select name,id from ecmpricebooks where deleted='0'");
|
||||
|
||||
$i=0;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result))
|
||||
{
|
||||
print '<tr>';
|
||||
print '<input type="hidden" name="pricebook_id['.$i.']" value="'.$row['id'].'">';
|
||||
|
||||
print '<td class="oddListRowS1" width="1%"><input onclick="ShowHideBlock(\'price_block_'.$row['id'].'\');" type="checkbox" name="check['.$i.']" value="'.$row['id'].'"></td>';
|
||||
|
||||
print '<td class="oddListRowS1"><a href="index.php?module=EcmProducts&action=DetailView&record='.$product_id.'">'.$product_name.'</a></td>';
|
||||
print '<td class="oddListRowS1"><a href="index.php?module=EcmPriceBooks&action=DetailView&record='.$row['id'].'">'.$row['name'].'</a></td>';
|
||||
print '<td class="oddListRowS1">'.number_format($purchase_price,2,",",".").'</td>';
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select price from ecmpricebooks_ecmproducts where ecmproduct_id='".$_REQUEST['product_id']."' and ecmpricebook_id='".$row['id']."'"));
|
||||
$price=$r['price'];
|
||||
|
||||
print '<td class="oddListRowS1">'.number_format($price,2,",",".").'</td>';
|
||||
print '<td>
|
||||
<div id="price_block_'.$row['id'].'" style="display:none;">
|
||||
<input onchange="getPrice(\''.$row['id'].'\',\'up\');" onclick="getPrice(\''.$row['id'].'\',\'down\');" name="purchase_price_'.$row['id'].'" type="text" id="purchase_price_'.$row['id'].'" value="'.$purchase_price.'" size="5" />
|
||||
<input onchange="getPrice(\''.$row['id'].'\',\'up\');" onclick="getPrice(\''.$row['id'].'\',\'down\');" name="margin_rate_'.$row['id'].'" type="text" id="margin_rate_'.$row['id'].'" value="20" size="2" />
|
||||
<input onchange="getPrice(\''.$row['id'].'\',\'up\');" onclick="getPrice(\''.$row['id'].'\',\'down\');" name="list_price_'.$row['id'].'" type="text" id="list_price_'.$row['id'].'" value="" size="6" />
|
||||
<script>getPrice(\''.$row['id'].'\',\'up\');</script></div></td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
print '<br><input class="button" type="submit" value="'.$mod_strings['LBL_UPDATE'].'">';
|
||||
print '</form>';
|
||||
|
||||
?>
|
||||
438
modules/EcmPriceBooks2/ListViewProductsAjax.php
Executable file
438
modules/EcmPriceBooks2/ListViewProductsAjax.php
Executable file
@@ -0,0 +1,438 @@
|
||||
<?
|
||||
set_time_limit(50);
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
//$GLOBALS['db']->query("SET NAMES 'utf8' COLLATE 'utf8_polish_ci'");
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_GET['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
$o=explode("||",$row['orders']);
|
||||
|
||||
if($_COOKIE['customview_id']!=$_GET['customview_id'] || $_SESSION['customview_id']=="" || !$_GET['order_by'])
|
||||
{
|
||||
$pbo=array();
|
||||
for($i=0;$i<=8;$i++)
|
||||
{
|
||||
if($o[$i])
|
||||
{
|
||||
$exp=explode(" ",$o[$i]);
|
||||
$adesc=$exp[1];
|
||||
$ord=$exp[0];
|
||||
if($ord=="list_price")$pbo[]="ecmpricebooks_ecmproducts.price ".$adesc;
|
||||
else $pbo[]="ecmproducts.".$ord." ".$adesc;
|
||||
}
|
||||
}
|
||||
$_SESSION['pricebook_order']=implode(",",$pbo);
|
||||
}
|
||||
setcookie('customview_id',$_GET['customview_id'],time()+60*24*60*3600);
|
||||
|
||||
$order=$_SESSION['pricebook_order'];
|
||||
$order=str_replace("ecmproducts.margin_rate","margin_rate",$order);
|
||||
if($_REQUEST['order_by']){
|
||||
$order=str_replace($_REQUEST['order_by']." desc",$_REQUEST['order_by']." ".$_REQUEST['sorder'],$order);
|
||||
$order=str_replace($_REQUEST['order_by']." asc",$_REQUEST['order_by']." ".$_REQUEST['sorder'],$order);
|
||||
}
|
||||
|
||||
$_SESSION['pricebook_order']=$order;
|
||||
|
||||
if($_REQUEST['order_by'] && $_REQUEST['sorder'])$_SESSION['pricebook_order']=$_REQUEST['order_by']." ".$_REQUEST['sorder'];
|
||||
|
||||
//if($_REQUEST['order_by'])$_SESSION['pricebook_order_by']=$_SESSION['pricebook_order']=$_REQUEST['order_by'];
|
||||
//$_SESSION['pricebook_sorder']=$_REQUEST['sorder'];
|
||||
$_SESSION['pricebook_sorder']=$_REQUEST['sorder'];
|
||||
$_COOKIE['pricebook_id']=$_REQUEST['pricebook_id'];
|
||||
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id,ecmlanguage,currency_value from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
$lang=$r['ecmlanguage'];
|
||||
$er_value=$r['currency_value'];
|
||||
if(!$er_value){
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
}
|
||||
$sorder=$_REQUEST['sorder'];
|
||||
$result = $GLOBALS['db']->query("select ecmpricebooks_ecmproducts.price as price,ecmpricebooks_ecmproducts.id as idp,ecmproducts.* from ecmpricebooks_ecmproducts left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id where ecmpricebooks_ecmproducts.ecmpricebook_id='".$_COOKIE['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'");
|
||||
$checkc='';
|
||||
$checkc.='if(document.getElementById(\'checkin\').checked==true)
|
||||
{
|
||||
mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=checkAllProducts&pricebook_id='.$_REQUEST['pricebook_id'].'&value=true\',\'checkin\');
|
||||
}
|
||||
else
|
||||
{
|
||||
mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=checkAllProducts&pricebook_id='.$_REQUEST['pricebook_id'].'&value=false\',\'checkin\');
|
||||
}';
|
||||
while($ro=$GLOBALS['db']->fetchByAssoc($result))
|
||||
{
|
||||
|
||||
$checkc.='if(document.getElementById(\'checkin\').checked==true)
|
||||
{
|
||||
document.getElementById(\'checkc'.$ro['idp'].'\').checked=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById(\'checkc'.$ro['idp'].'\').checked=false;
|
||||
}
|
||||
';
|
||||
}
|
||||
print '</tr>';
|
||||
$z="select
|
||||
ecmpricebooks_ecmproducts.price as price,
|
||||
ecmpricebooks_ecmproducts.popular as popular,
|
||||
ecmpricebooks_ecmproducts.recipient_code as recipient_code,
|
||||
ecmpricebooks_ecmproducts.id as idp,
|
||||
ecmpricebooks_ecmproducts.margin_rate,
|
||||
ecmpricebooks_ecmproducts.position as position,
|
||||
ecmpricebooks_ecmproducts.remarks_pl as remarks_pl,
|
||||
ecmpricebooks_ecmproducts.remarks_en as remarks_en,
|
||||
ecmpricebooks_ecmproducts.remarks_de as remarks_de,
|
||||
ecmproducts.*,
|
||||
|
||||
ecmproduct_language_pl_view.ean as ean_pl,
|
||||
ecmproduct_language_pl_view.short_description as short_description_pl,
|
||||
ecmproduct_language_pl_view.long_description as long_description_pl,
|
||||
ecmproduct_language_pl_view.remarks as default_remarks_pl,
|
||||
|
||||
ecmproduct_language_en_view.ean as ean_en,
|
||||
ecmproduct_language_en_view.short_description as short_description_en,
|
||||
ecmproduct_language_en_view.long_description as long_description_en,
|
||||
ecmproduct_language_en_view.remarks as default_remarks_en,
|
||||
|
||||
ecmproduct_language_de_view.ean as ean_de,
|
||||
ecmproduct_language_de_view.short_description as short_description_de,
|
||||
ecmproduct_language_de_view.long_description as long_description_de,
|
||||
ecmproduct_language_de_view.remarks as default_remarks_de
|
||||
|
||||
from ecmpricebooks_ecmproducts
|
||||
|
||||
left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
where ecmpricebooks_ecmproducts.ecmpricebook_id='".$_REQUEST['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'";
|
||||
|
||||
$tmp = substr(trim($_SESSION['pricebook_order']), -1);
|
||||
if ($tmp!='.')
|
||||
if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order'];
|
||||
|
||||
//$z.=" COLLATE utf8_polish_ci";
|
||||
//print $z;
|
||||
|
||||
|
||||
if ($_REQUEST['customview_id']=='4cf54ba0-db9b-dc0d-e781-522f24a92e60') {
|
||||
$ttttt = '
|
||||
<br><br>
|
||||
<form action="index.php?module=EcmPriceBooks&action=updatePrices&record='.$_REQUEST['pricebook_id'].'" method="post">
|
||||
Marża: <input id="margin" name="margin" type="text" value="0"/> 
|
||||
Rabat: <input id="discount" name="discount" type="text" value="0"/> 
|
||||
Cena z VAT: <input id="with_tax" name="with_tax" type="checkbox"/> 
|
||||
Rodzaj przeliczania:
|
||||
<select id="type" name="type"/>
|
||||
<option value="1">Od dołu</option>
|
||||
<option value="2">Od góry</option>
|
||||
</select>
|
||||
<input type="submit" value="Przelicz ceny"/>
|
||||
<br><br>
|
||||
</form>
|
||||
';
|
||||
echo $ttttt;
|
||||
}
|
||||
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
include_once("modules/EcmProductReports/vtigerConnector.php");
|
||||
$count = $result->num_rows;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result))
|
||||
{
|
||||
if ($licz%100==0 && $licz>0) {
|
||||
print '</table>';
|
||||
print '<input type="submit" name="save_prices" class="button" value="Save">';
|
||||
print '</form>';
|
||||
}
|
||||
if ($licz%100==0) {
|
||||
print '<form action="index.php?module=EcmPriceBooks&action=SavePrices&record='.$_REQUEST['pricebook_id'].'" method="post">';
|
||||
print '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="ListView"><tr>';
|
||||
print '<td class="listViewThS1" width="1%"><input type="checkbox" id="checkin" value="true" onclick="'.$checkc.'"';
|
||||
if($_SESSION['pricebook_check'][$_REQUEST['pricebook_id']]['all']=="true"){print ' checked';}
|
||||
print '></td>';
|
||||
print '<td class="listViewThS1">'.sortLink("ecmpricebooks_ecmproducts.position",$sorder,"Pos.").'</td>';
|
||||
//print mysql_error();
|
||||
$t[1]='Nazwa';
|
||||
$t[2]='Kategoria';
|
||||
for($i=0;$i<count($t);$i++)
|
||||
{
|
||||
$corder_by="ecmproducts.".$c[$i];
|
||||
if($c[$i]=="list_price")$corder_by="ecmpricebooks_ecmproducts.price";
|
||||
|
||||
if($c[$i]=="ean_pl")$corder_by="ecmproduct_language_pl_view.ean";
|
||||
if($c[$i]=="short_description_pl")$corder_by="ecmproduct_language_pl_view.short_description";
|
||||
if($c[$i]=="long_description_pl")$corder_by="ecmproduct_language_pl_view.long_description";
|
||||
if($c[$i]=="default_remarks_pl")$corder_by="ecmproduct_language_pl_view.remarks";
|
||||
|
||||
if($c[$i]=="remarks_pl")$corder_by="ecmpricebooks_ecmproducts.remarks_pl";
|
||||
|
||||
if($c[$i]=="ean_en")$corder_by="ecmproduct_language_en_view.ean";
|
||||
if($c[$i]=="short_description_en")$corder_by="ecmproduct_language_en_view.short_description";
|
||||
if($c[$i]=="long_description_en")$corder_by="ecmproduct_language_en_view.long_description";
|
||||
if($c[$i]=="default_remarks_en")$corder_by="ecmproduct_language_en_view.remarks";
|
||||
|
||||
if($c[$i]=="remarks_en")$corder_by="ecmpricebooks_ecmproducts.remarks_en";
|
||||
|
||||
if($c[$i]=="ean_de")$corder_by="ecmproduct_language_de_view.ean";
|
||||
if($c[$i]=="short_description_de")$corder_by="ecmproduct_language_de_view.short_description";
|
||||
if($c[$i]=="long_description_de")$corder_by="ecmproduct_language_de_view.long_description";
|
||||
if($c[$i]=="default_remarks_de")$corder_by="ecmproduct_language_de_view.remarks";
|
||||
|
||||
if($c[$i]=="remarks_de")$corder_by="ecmpricebooks_ecmproducts.remarks_de";
|
||||
|
||||
if($c[$i]=="margin_rate")$corder_by="margin_rate";
|
||||
|
||||
if($c[$i]=="sale_qty30")$corder_by="name";
|
||||
if($c[$i]=="sale_qty90")$corder_by="name";
|
||||
if($c[$i]=="sale_qty180")$corder_by="name";
|
||||
if($c[$i]=="sale_avg_price30")$corder_by="name";
|
||||
if($c[$i]=="sale_avg_price90")$corder_by="name";
|
||||
if($c[$i]=="sale_avg_price180")$corder_by="name";
|
||||
|
||||
|
||||
|
||||
if($t[$i])print '<td class="listViewThS1">'.sortLink($corder_by,$sorder,$t[$i]).'</td>';
|
||||
}
|
||||
$mm=$mod_strings;
|
||||
print '<td class="listViewThS1" width="1%">Popularność</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_UNIT_PRICE'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_MARGIN'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_LIST_PRICE_PRICEBOOK'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%">Cena brutto</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_RECIPIENT_CODE'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_REMARKS_PL'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_REMARKS_EN'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_REMARKS_DE'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%"> </td>';
|
||||
print '<td class="listViewThS1" width="1%"> </td>';
|
||||
print '<td class="listViewThS1" width="1%"> </td>';
|
||||
}
|
||||
|
||||
$stop[$row['code']]=false;
|
||||
$sale30="";
|
||||
$qty30="";
|
||||
$sale90="";
|
||||
$qty90="";
|
||||
$sale180="";
|
||||
$qty180="";
|
||||
if($_SESSION['EcmPriceBooks_high'][$row['idp']])$color="#cccccc";
|
||||
else $color="";
|
||||
$licz++;
|
||||
print '<tr id="row'.$row['idp'].'" style="background:'.$color.'">';
|
||||
|
||||
print '<td class="oddListRowS1"><input type="hidden" id="check'.$row['idp'].'"><input id="checkc'.$row['idp'].'" onclick="mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=checkProduct&record='.$row['idp'].'&pricebook_id='.$_REQUEST['pricebook_id'].'&value=\'+this.checked,\'check'.$row['idp'].'\');" type="checkbox" name="check[]" value="'.$row['idp'].'"';
|
||||
if($_SESSION['pricebook_check'][$_REQUEST['pricebook_id']]['all']=="true" || $_SESSION['pricebook_check'][$_REQUEST['pricebook_id']][$row['idp']]=="true")print ' checked';
|
||||
print '></td>';
|
||||
print '<td class="oddListRowS1">'.($row['position']).'</td>';
|
||||
//print '<td class="oddListRowS1"><a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">'.$row['name'].'</a></td>';
|
||||
|
||||
/*$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select purchase_price from ecmproducts where id='".$row['id']."'"));
|
||||
$purchase_price=$rr['purchase_price'];
|
||||
@$margin=100-(100*$purchase_price/$row['price']);
|
||||
$margin=number_format($margin,2,",",".");*/
|
||||
for($i=0;$i<count($t);$i++)
|
||||
{
|
||||
if($t[$i])
|
||||
{
|
||||
|
||||
if(($c[$i]=="sale_qty30" || $c[$i]=="sale_qty90" || $c[$i]=="sale_qty180" || $c[$i]=="sale_avg_price30" || $c[$i]=="sale_avg_price90" || $c[$i]=="sale_avg_price180") && $stop[$row['code']]==false){
|
||||
$ddate=date("Y-m-d",mktime()-200*24*3600);
|
||||
|
||||
$w=$GLOBALS['db']->query("select ecminvoiceoutitems.price as price,ecminvoiceoutitems.quantity as quantity,ecminvoiceouts.register_date as date from ecminvoiceoutitems inner join ecminvoiceouts on ecminvoiceoutitems.ecminvoiceout_id=ecminvoiceouts.id where ecminvoiceoutitems.ecmproduct_id='".$row['id']."' and ecminvoiceouts.type!='correct' and ecminvoiceouts.register_date>'".$ddate."'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$sale+=$r['price']*$r['quantity'];
|
||||
$qty+=$r['quantity'];
|
||||
$aq[$r['no']]+=$r['quantity'];
|
||||
|
||||
$date=date("Y-m");
|
||||
|
||||
$date1=date("Y-m",mktime()-1*24*3600*31);
|
||||
$date2=date("Y-m",mktime()-2*24*3600*31);
|
||||
$date3=date("Y-m",mktime()-3*24*3600*31);
|
||||
$date4=date("Y-m",mktime()-4*24*3600*31);
|
||||
$date5=date("Y-m",mktime()-5*24*3600*31);
|
||||
$date6=date("Y-m",mktime()-6*24*3600*31);
|
||||
|
||||
$d=explode("-",$r['date']);
|
||||
|
||||
$dd=$d[0]."-".$d[1];
|
||||
if($dd==$date6){
|
||||
//echo 3;
|
||||
$qty_6+=$r['quantity'];
|
||||
}
|
||||
|
||||
if($dd==$date5){
|
||||
//echo 3;
|
||||
$qty_5+=$r['quantity'];
|
||||
}
|
||||
|
||||
if($dd==$date4){
|
||||
//echo 3;
|
||||
$qty_4+=$r['quantity'];
|
||||
}
|
||||
|
||||
if($dd==$date3){
|
||||
//echo 3;
|
||||
$qty_3+=$r['quantity'];
|
||||
}
|
||||
|
||||
if($dd==$date2){
|
||||
//echo 2;
|
||||
$qty_2+=$r['quantity'];
|
||||
}
|
||||
|
||||
if($dd==$date1){
|
||||
//echo 1;
|
||||
$qty_1+=$r['quantity'];
|
||||
}
|
||||
|
||||
if($dd==$date){
|
||||
$sale0+=$r['price']*$r['quantity'];
|
||||
$qty0+=$r['quantity'];
|
||||
$aq0[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date1){
|
||||
$sale30+=$r['price']*$r['quantity'];
|
||||
$qty30+=$r['quantity'];
|
||||
$aq30[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date1 || $dd==$date2 || $dd==$date3){
|
||||
$sale90+=$r['price']*$r['quantity'];
|
||||
$qty90+=$r['quantity'];
|
||||
$aq90[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date1 || $dd==$date2 || $dd==$date3 || $dd==$date4 || $dd==$date5 || $dd==$date6){
|
||||
$sale180+=$r['price']*$r['quantity'];
|
||||
$qty180+=$r['quantity'];
|
||||
$aq180[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@$trend_6_5=$qty_5/$qty_6;
|
||||
@$trend_5_4=$qty_4/$qty_5;
|
||||
@$trend_4_3=$qty_3/$qty_4;
|
||||
@$trend_3_2=$qty_2/$qty_3;
|
||||
@$trend_2_1=$qty_1/$qty_2;
|
||||
|
||||
$trend=($qty_1+$qty_2+$qty_3)/3;
|
||||
|
||||
$qty__1=$trend;
|
||||
$qty__2=$trend;
|
||||
$qty__3=$trend;
|
||||
|
||||
if($qty__1<0)$qty__1=0;
|
||||
if($qty__2<0)$qty__2=0;
|
||||
if($qty__3<0)$qty__3=0;
|
||||
|
||||
$stop[$row['code']]=true;
|
||||
}
|
||||
|
||||
|
||||
print '<td class="oddListRowS1">';
|
||||
if($c[$i]=="ordered")print number_format($row['ordered'],0,"","");
|
||||
elseif($c[$i]=="sale_qty30")print number_format($qty30,0,"","");
|
||||
elseif($c[$i]=="sale_qty90")print number_format($qty90/3,0,"","");
|
||||
elseif($c[$i]=="sale_qty180")print number_format($qty180/6,0,"","");
|
||||
elseif($c[$i]=="sale_avg_price30")print number_format($sale30,2,",",".");
|
||||
elseif($c[$i]=="sale_avg_price90")print number_format($sale90,2,",",".");
|
||||
elseif($c[$i]=="sale_avg_price180")print number_format($sale180,2,",",".");
|
||||
elseif($c[$i]=="ems_qty_in_stock")print number_format($row['ems_qty_in_stock'],0,"","");
|
||||
elseif($c[$i]=="list_price")print addExchangeRateValue($row['price'],$c[$i],$er_value);
|
||||
elseif($c[$i]=="margin_rate")print number_format($row['margin_rate'],2,",",".");
|
||||
elseif($c[$i]=="name"){
|
||||
if($lang=="en_us"){
|
||||
if($row['short_description_en'])print '<a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">'.$row['short_description_en'].'</a>';
|
||||
else print '<a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">none</a>';
|
||||
}
|
||||
elseif($lang=="ge_ge"){
|
||||
if($row['short_description_de'])print '<a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">'.$row['short_description_de'].'</a>';
|
||||
else print '<a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">none</a>';
|
||||
}
|
||||
else print '<a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">'.$row['name'].'</a>';
|
||||
}
|
||||
elseif($c[$i]=="product_category_name"){
|
||||
if($lang=="en_us"){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_en from ecmproductcategories where id='".$row['product_category_id']."'"));
|
||||
if($rrp['name_en'])print $rrp['name_en'];
|
||||
}
|
||||
elseif($lang=="ge_ge"){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_de from ecmproductcategories where id='".$row['product_category_id']."'"));
|
||||
if($rrp['name_de'])print $rrp['name_de'];
|
||||
}
|
||||
else print $row['product_category_name'];
|
||||
print ' <a target="_blank" href="index.php?record='.$_REQUEST['pricebook_id'].'&to_pdf=1&action=generateCategoryContent&module=EcmProducts&category_id='.$row['product_category_id'].'&category_name='.$row['product_category_name'].'&lang='.$lang.'"><img src="themes/default/images/PDFlanguages.gif" border="0" /></a>';
|
||||
}
|
||||
else print addExchangeRateValue($row[$c[$i]],$c[$i],$er_value);
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($row['popular']==1)$po_checked="checked";
|
||||
else $po_checked="";
|
||||
print '<td>
|
||||
<input size="8" id="popular_'.$licz.'" name="popular_'.$licz.'" readonly type="checkbox" value="1" '.$po_checked.'/>
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="purchase_price_'.$licz.'" name="purchase_price_'.$licz.'" readonly type="text" onchange="getPricePricebook();" onclick="getPricePricebook();" onblur="getPricePricebook();" value="'.number_format($row['purchase_price'],2,",",".").'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="4" id="margin_'.$licz.'" name="margin_'.$licz.'" type="text" onchange="getPricePricebook();" onclick="getPricePricebook();" onblur="getPricePricebook();" value="'.number_format($row['margin_rate'],2,",",".").'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="price_'.$licz.'" name="price_'.$licz.'" type="text" onchange="getPricePricebook();" onclick="getPricePricebook();" onblur="getPricePricebook();" value="'.number_format($row['price'],2,",",".").'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="price_brutto_'.$licz.'" name="price_brutto_'.$licz.'" type="text" onchange="getPricePricebook();" onclick="getPricePricebook();" onblur="getPricePricebook();" value="'.number_format(($row['price']*(1+$row['vat_value']/100)),2,",",".").'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="recipient_code_'.$licz.'" name="recipient_code_'.$licz.'" type="text" value="'.$row['recipient_code'].'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="remarks_pl_'.$licz.'" name="remarks_pl_'.$licz.'" type="text" value="'.$row['remarks_pl'].'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="remarks_en_'.$licz.'" name="remarks_en_'.$licz.'" type="text" value="'.$row['remarks_en'].'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="remarks_de_'.$licz.'" name="remarks_de_'.$licz.'" type="text" value="'.$row['remarks_de'].'" />
|
||||
</td>
|
||||
<td>
|
||||
<input id="product_id_'.$licz.'" name="product_id_'.$licz.'" type="hidden" value="'.$row['idp'].'" /></td>';
|
||||
|
||||
|
||||
print '<td class="oddListRowS1">
|
||||
<a id="edit'.$row['id'].'" style="cursor:pointer;" onclick="document.getElementById(\'row'.$row['idp'].'\').style.background=\'#e6e6e6\';showdiv(\'edit'.$row['id'].'\',\'price-block\',80,240);showprice(\''.$row['id'].'\',\''.number_format($row['price'],2,",",".").'\',\''.number_format($row['purchase_price'],2,",",".").'\',\''.number_format($row['margin_rate'],2,",",".").'\',\''.$row['remarks_pl'].'\',\''.$row['remarks_en'].'\',\''.$row['remarks_de'].'\',\''.$_REQUEST['order_by'].'\',\''.$_REQUEST['sorder'].'\',\''.$row['recipient_code'].'\');"><img src="themes/Sugar/images/edit_inline.gif" border="0"></a>';
|
||||
print '<td class="oddListRowS1">
|
||||
<a id="delete'.$row['id'].'" style="cursor:pointer;" onclick="if(confirm(\''.$mod_strings['LBL_QUESTION_DELETE'].'\')){mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=deleteProductFromPriceBook&id='.$row['idp'].'\',\'row'.$row['idp'].'\');document.getElementById(\'row'.$row['idp'].'\').style.display=\'none\';}"><img src="themes/Sugar/images/delete_inline.gif" border="0"></a>
|
||||
</td>';
|
||||
print '</tr>';
|
||||
if ($licz==$count) {
|
||||
print '</table>';
|
||||
print '<input type="submit" name="save_prices" class="button" value="Save">';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//print '</table>';
|
||||
print '<div style="text-align:left"><br><input class="button" value="Delete" name="delete" type="button" onclick="if(confirm(\'Are You sure?\'))location.href=\'index.php?module=EcmPriceBooks&action=DeleteFromPriceBook&but=1&return_id='.$_COOKIE['pricebook_id'].'\';"></div>';
|
||||
|
||||
?>
|
||||
68
modules/EcmPriceBooks2/Menu.php
Executable file
68
modules/EcmPriceBooks2/Menu.php
Executable file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
if (!defined('sugarEntry') || !sugarEntry)
|
||||
die('Not A Valid Entry Point');
|
||||
/* * ***************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
* ****************************************************************************** */
|
||||
|
||||
$module_menu[]=Array(
|
||||
'action' => 'EditView',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'showName' => $mod_strings['LNK_NEW_ECMPRICEBOOKS'],
|
||||
'icon' => 'pricebookadd.png',
|
||||
'parentTab' => 'EcmProducts'
|
||||
);
|
||||
$module_menu[]=Array(
|
||||
'action' => 'index',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'showName' => $mod_strings['LNK_ECMPRICEBOOKS_LIST'],
|
||||
'icon' => 'pricebook.png',
|
||||
'parentTab' => 'EcmProducts'
|
||||
);
|
||||
|
||||
?>
|
||||
5
modules/EcmPriceBooks2/PDF.php
Executable file
5
modules/EcmPriceBooks2/PDF.php
Executable file
@@ -0,0 +1,5 @@
|
||||
<?
|
||||
session_start();
|
||||
$_SESSION['pricebook_images']=$_REQUEST['images'];
|
||||
header("Location: modules/EcmPriceBooks/CreatePDF.php");
|
||||
?>
|
||||
57
modules/EcmPriceBooks2/Popup.php
Executable file
57
modules/EcmPriceBooks2/Popup.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
require_once('modules/EcmPriceBooks/Popup_picker.php');
|
||||
|
||||
$popup = new Popup_Picker();
|
||||
|
||||
echo $popup->process_page();
|
||||
|
||||
?>
|
||||
154
modules/EcmPriceBooks2/Popup_picker.php
Executable file
154
modules/EcmPriceBooks2/Popup_picker.php
Executable file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
global $theme;
|
||||
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once('themes/'.$theme.'/layout_utils.php');
|
||||
require_once('log4php/LoggerManager.php');
|
||||
require_once('XTemplate/xtpl.php');
|
||||
require_once('include/ListView/ListView.php');
|
||||
$image_path = 'themes/'.$theme.'/images/';
|
||||
|
||||
class Popup_Picker{
|
||||
|
||||
function Popup_Picker(){
|
||||
;
|
||||
}
|
||||
|
||||
function _get_where_clause(){
|
||||
$where = '';
|
||||
if(isset($_REQUEST['query'])){
|
||||
$where_clauses = array();
|
||||
append_where_clause($where_clauses, "name", "ecmpricebooks.name");
|
||||
$where = generate_where_statement($where_clauses);
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
function process_page(){
|
||||
global $theme;
|
||||
global $mod_strings;
|
||||
global $app_strings;
|
||||
global $currentModule;
|
||||
|
||||
$output_html = '';
|
||||
$where = '';
|
||||
$where = $this->_get_where_clause();
|
||||
|
||||
$image_path = 'themes/'.$theme.'/images/';
|
||||
|
||||
$name = empty($_REQUEST['name']) ? '' : $_REQUEST['name'];
|
||||
$request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
|
||||
$hide_clear_button = empty($_REQUEST['hide_clear_button']) ? false : true;
|
||||
$button = "<form action='index.php' method='post' name='form' id='form'>\n";
|
||||
if(!$hide_clear_button){
|
||||
$button .= "<input type='button' name='button' class='button' onclick=\"send_back('','');\" title='"
|
||||
.$app_strings['LBL_CLEAR_BUTTON_TITLE']."' accesskey='"
|
||||
.$app_strings['LBL_CLEAR_BUTTON_KEY'] ."' value=' "
|
||||
.$app_strings['LBL_CLEAR_BUTTON_LABEL']." ' />\n";
|
||||
}
|
||||
$button .= "<input type='submit' name='button' class='button' onclick=\"window.close();\" title='"
|
||||
.$app_strings['LBL_CANCEL_BUTTON_TITLE']."' accesskey='"
|
||||
.$app_strings['LBL_CANCEL_BUTTON_KEY'] ."' value=' "
|
||||
.$app_strings['LBL_CANCEL_BUTTON_LABEL']." ' />\n";
|
||||
$button .= "</form>\n";
|
||||
$form = new XTemplate('modules/EcmPriceBooks/Popup_picker.html');
|
||||
$form->assign('MOD', $mod_strings);
|
||||
$form->assign('APP', $app_strings);
|
||||
$form->assign('THEME', $theme);
|
||||
$form->assign('MODULE_NAME', $currentModule);
|
||||
$form->assign('NAME', $name);
|
||||
$form->assign('request_data', $request_data);
|
||||
$form->assign('PRICEBOOK_PRODUCT_ID', $_REQUEST['pricebook_product_id']);
|
||||
$form->assign('EXCHANGE_RATE_ID', $_REQUEST['exchange_rate_id']);
|
||||
|
||||
ob_start();
|
||||
insert_popup_header($theme);
|
||||
$output_html .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$output_html .= get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false);
|
||||
|
||||
$form->parse('main.SearchHeader');
|
||||
$output_html .= $form->text('main.SearchHeader');
|
||||
$output_html .= get_form_footer();
|
||||
|
||||
// RESET THE SECTIONS THAT ARE ALREADY IN THE PAGE SO THAT THEY DO NOT PRINT AGAIN LATER.
|
||||
$form->reset('main.SearchHeader');
|
||||
|
||||
// CREATE THE LISTVIEW
|
||||
$seed_bean = new EcmPriceBook();
|
||||
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select price from ecmpricebooks_ecmproducts where ecmproduct_id='".$_REQUEST['pricebook_product_id']."' and ecmpricebook_id='".$seed_bean->id."'"));
|
||||
$seed_bean->price=$r['price'];
|
||||
|
||||
$ListView = new ListView();
|
||||
$ListView->show_export_button = false;
|
||||
$ListView->process_for_popups = true;
|
||||
$ListView->setXTemplate($form);
|
||||
$ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']);
|
||||
$ListView->setHeaderText($button);
|
||||
|
||||
$ListView->setQuery($where, '', 'name', 'ECMPRICEBOOK');
|
||||
$ListView->setModStrings($mod_strings);
|
||||
|
||||
ob_start();
|
||||
$ListView->processListView($seed_bean, 'main', 'ECMPRICEBOOK');
|
||||
$output_html .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$output_html .= get_form_footer();
|
||||
$output_html .= insert_popup_footer();
|
||||
return $output_html;
|
||||
}
|
||||
} // end of class Popup_Picker
|
||||
?>
|
||||
115
modules/EcmPriceBooks2/Save.php
Executable file
115
modules/EcmPriceBooks2/Save.php
Executable file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once('include/formbase.php');
|
||||
|
||||
|
||||
$focus = new EcmPriceBook();
|
||||
|
||||
$focus->retrieve($_POST['record']);
|
||||
if(!$focus->ACLAccess('Save')){
|
||||
ACLController::displayNoAccess(true);
|
||||
sugar_cleanup(true);
|
||||
}
|
||||
if (!empty($_POST['assigned_user_id']) && ($focus->assigned_user_id != $_POST['assigned_user_id']) && ($_POST['assigned_user_id'] != $current_user->id)) {
|
||||
$check_notify = TRUE;
|
||||
}else{
|
||||
$check_notify = FALSE;
|
||||
}
|
||||
|
||||
foreach($focus->column_fields as $field){
|
||||
if(isset($_POST[$field])){
|
||||
$value = $_POST[$field];
|
||||
$focus->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($focus->additional_column_fields as $field){
|
||||
if(isset($_POST[$field])){
|
||||
$value = $_POST[$field];
|
||||
$focus->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_POST[ekmp_active])) {
|
||||
$focus->ekmp_active = '0';
|
||||
}else{
|
||||
$focus->ekmp_active = '1';
|
||||
}
|
||||
$focus->account_name=$_REQUEST['account_name'];
|
||||
$focus->unformat_all_fields();
|
||||
$focus->save($check_notify);
|
||||
$return_id = $focus->id;
|
||||
|
||||
if(!$_REQUEST['currency_value']){
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($_REQUEST['exchange_rate_id']);
|
||||
$er_value=$currency->conversion_rate;
|
||||
}
|
||||
else $er_value=unformat_number($_REQUEST['currency_value']);
|
||||
|
||||
|
||||
|
||||
$GLOBALS['db']->query("update ecmpricebooks set currency_value='".$er_value."',account_name='".$_POST['account_name']."' where id='".$return_id."'");
|
||||
echo $_SESSION['pricebook_duplicate_id'].'<br>';
|
||||
echo $_POST['duplicateSave'].'<br>';
|
||||
|
||||
if($_SESSION['pricebook_duplicate_id'] && $_POST['duplicateSave']=="true"){
|
||||
$w=$GLOBALS['db']->query("select * from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_SESSION['pricebook_duplicate_id']."'");
|
||||
$_SESSION['pricebook_duplicate_id']="";
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)) {
|
||||
$GLOBALS['db']->query("insert into ecmpricebooks_ecmproducts values('".create_guid()."','".$return_id."','".$r['ecmproduct_id']."','".$r['deleted']."','".$r['price']."','".$r['recipient_code']."','".$r['created_by']."','".$r['remarks_pl']."','".$r['remarks_en']."','".$r['remarks_de']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','".$_SESSION['authenticated_user_id']."','".$r['popular']."','".$r['position']."', '".$r['margin_rate']."');");
|
||||
}
|
||||
}
|
||||
handleRedirect($return_id,'EcmPriceBooks');
|
||||
|
||||
?>
|
||||
33
modules/EcmPriceBooks2/SaveCustomView.php
Executable file
33
modules/EcmPriceBooks2/SaveCustomView.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?
|
||||
global $db;
|
||||
|
||||
require("modules/EcmProducts/vardefs.php");
|
||||
require("modules/EcmProducts/language/en_us.lang.php");
|
||||
|
||||
$fields=$dictionary['EcmProduct']['fields'];
|
||||
|
||||
$columns=$_REQUEST['column1']."||".$_REQUEST['column2']."||".$_REQUEST['column3']."||".$_REQUEST['column4']."||".$_REQUEST['column5']."||".$_REQUEST['column6']."||".$_REQUEST['column7']."||".$_REQUEST['column8']."||".$_REQUEST['column9'];
|
||||
|
||||
$fields=$dictionary['EcmProduct']['fields'];
|
||||
|
||||
for($i=1;$i<=9;$i++)
|
||||
{
|
||||
$str=$fields[$_REQUEST['column'.$i]]['vname'];
|
||||
if(!$_REQUEST['title'.$i])$_REQUEST['title'.$i]=$mod_strings[$str];
|
||||
}
|
||||
|
||||
$titles=$_REQUEST['title1']."||".$_REQUEST['title2']."||".$_REQUEST['title3']."||".$_REQUEST['title4']."||".$_REQUEST['title5']."||".$_REQUEST['title6']."||".$_REQUEST['title7']."||".$_REQUEST['title8']."||".$_REQUEST['title9'];
|
||||
|
||||
for($i=1;$i<=9;$i++){
|
||||
if($_REQUEST['order'.$i] && $_REQUEST['sorder'.$i]){
|
||||
$ord[$i]=$_REQUEST['order'.$i]." ".$_REQUEST['sorder'.$i];
|
||||
}
|
||||
}
|
||||
|
||||
$orders=implode("||",$ord);
|
||||
|
||||
if($_REQUEST['record'])$db->query("update ecmpricebooks_customview set name='".$_REQUEST['name']."',columns='".$columns."',titles='".$titles."',orders='".$orders."' where id='".$_REQUEST['record']."'");
|
||||
else $db->query("insert into ecmpricebooks_customview values('".create_guid()."','".$_REQUEST['name']."','".$columns."','".$titles."','".$orders."')");
|
||||
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_SESSION['pricebook_id']."&tab=items");
|
||||
?>
|
||||
10
modules/EcmPriceBooks2/SaveOrder.php
Executable file
10
modules/EcmPriceBooks2/SaveOrder.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<?
|
||||
for($i=0;$i<=$_REQUEST['num'];$i++)
|
||||
{
|
||||
if($_REQUEST['c'.$i])$v[]=$_REQUEST['c'.$i];
|
||||
}
|
||||
$value=implode(",",$v);
|
||||
$_SESSION['columns_order']=$value;
|
||||
$_SESSION['pricebook_order']=str_replace(","," asc,",$value)." asc";
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_REQUEST['record']."&tab=items");
|
||||
?>
|
||||
15
modules/EcmPriceBooks2/SavePrice.php
Executable file
15
modules/EcmPriceBooks2/SavePrice.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?
|
||||
$sugarEntry=true;
|
||||
global $db;
|
||||
function priceToDb($v){
|
||||
$v=str_replace(".","",$v);
|
||||
$v=str_replace(",",".",$v);
|
||||
return floatval($v);
|
||||
}
|
||||
$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set recipient_code='".$_REQUEST['recipient_code']."',remarks_pl='".$_REQUEST['remarks_pl']."',remarks_en='".$_REQUEST['remarks_en']."',remarks_de='".$_REQUEST['remarks_de']."',price='".priceToDb($_REQUEST['price'])."' where ecmpricebook_id='".$_REQUEST['pricebook_id']."' and ecmproduct_id='".$_REQUEST['record']."'");
|
||||
$_REQUEST['customview_id']=$_COOKIE['customview_id'];
|
||||
$_GET['customview_id']=$_COOKIE['customview_id'];
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts where ecmproduct_id='".$_REQUEST['record']."' and ecmpricebook_id='".$_REQUEST['pricebook_id']."'"));
|
||||
$_SESSION['EcmPriceBooks_high'][$r['id']]=true;
|
||||
include("modules/EcmPriceBooks/ListViewProductsAjax.php");
|
||||
?>
|
||||
27
modules/EcmPriceBooks2/SavePrices.php
Executable file
27
modules/EcmPriceBooks2/SavePrices.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?
|
||||
$sugarEntry=true;
|
||||
global $db;
|
||||
function priceToDb($v){
|
||||
$v=str_replace(".","",$v);
|
||||
$v=str_replace(",",".",$v);
|
||||
return floatval($v);
|
||||
}
|
||||
for($i=1;$i<=1000;$i++){
|
||||
if (!$_REQUEST['product_id_'.$i]) continue;
|
||||
$prod = $_REQUEST['product_id_'.$i];
|
||||
if($_REQUEST['product_id_'.$i]){
|
||||
$rp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select ecmproduct_id,price from ecmpricebooks_ecmproducts where id='".$_REQUEST['product_id_'.$i]."' and deleted='0'"));
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select vat_value from ecmproducts where id='".$rp['ecmproduct_id']."'"));
|
||||
$price=priceToDb($_REQUEST['price_brutto_'.$i])/(1+$r['vat_value']/100);
|
||||
if($rp['price']!=priceToDb($_REQUEST['price_'.$i]) || $_REQUEST['price_'.$i]=="")$price=priceToDb($_REQUEST['price_'.$i]);
|
||||
$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set popular='".$_REQUEST['popular_'.$i]."',recipient_code='".$_REQUEST['recipient_code_'.$i]."',remarks_pl='".$_REQUEST['remarks_pl_'.$i]."',remarks_en='".$_REQUEST['remarks_en_'.$i]."',remarks_de='".$_REQUEST['remarks_de_'.$i]."',price='".$price."' where id='".$_REQUEST['product_id_'.$i]."'");
|
||||
$_SESSION['EcmPriceBooks_high'][$_REQUEST['product_id_'.$i]]=true;
|
||||
}
|
||||
}
|
||||
$_REQUEST['customview_id']=$_COOKIE['customview_id'];
|
||||
$_GET['customview_id']=$_COOKIE['customview_id'];
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select ecmpricebook_id from ecmpricebooks_ecmproducts where id='".$prod."'"));
|
||||
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$r['ecmpricebook_id']."&tab=items");
|
||||
?>
|
||||
130
modules/EcmPriceBooks2/SubPanelView.php
Executable file
130
modules/EcmPriceBooks2/SubPanelView.php
Executable file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
require_once('XTemplate/xtpl.php');
|
||||
require_once("data/Tracker.php");
|
||||
require_once("include/ListView/ListView.php");
|
||||
|
||||
global $app_strings;
|
||||
global $current_language;
|
||||
$current_module_strings = return_module_language($current_language, 'EcmPriceBooks');
|
||||
$header_text = '';
|
||||
global $currentModule;
|
||||
global $theme;
|
||||
global $focus;
|
||||
global $action;
|
||||
|
||||
$theme_path="themes/".$theme."/";
|
||||
$image_path=$theme_path."images/";
|
||||
require_once($theme_path.'layout_utils.php');
|
||||
|
||||
///////////////////////////////////////
|
||||
/// SETUP PARENT POPUP
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return_and_save',
|
||||
'form_name' => 'DetailView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'ecmpricebook_id',
|
||||
),
|
||||
);
|
||||
$json = getJSONobj();
|
||||
$encoded_popup_request_data = $json->encode($popup_request_data);
|
||||
///
|
||||
///////////////////////////////////////
|
||||
|
||||
// FOCUS_LIST IS THE MEANS OF PASSING DATA TO A SUBPANELVIEW.
|
||||
global $focus_list;
|
||||
|
||||
$button = "<form action='index.php' method='post' name='form' id='form'>\n";
|
||||
$button .= "<input type='hidden' name='module' value='EcmPriceBooks'>\n";
|
||||
|
||||
if ($currentModule == 'Accounts') {
|
||||
$button .= "<input type='hidden' name='account_id' value='$focus->id'>\n";
|
||||
$button .= "<input type='hidden' name='account_name' value='$focus->name'>\n";
|
||||
|
||||
}elseif ($currentModule == 'Contacts') {
|
||||
$button .= "<input type='hidden' name='account_id' value='$focus->account_id'>\n";
|
||||
$button .= "<input type='hidden' name='account_name' value='$focus->account_name'>\n";
|
||||
$button .= "<input type='hidden' name='contact_id' value='$focus->id'>\n";
|
||||
|
||||
}elseif ($currentModule == 'Cases') {
|
||||
$button .= "<input type='hidden' name='case_id' value='$focus->id'>\n";
|
||||
}
|
||||
|
||||
$button .= "<input type='hidden' name='return_module' value='".$currentModule."'>\n";
|
||||
$button .= "<input type='hidden' name='return_action' value='".$action."'>\n";
|
||||
$button .= "<input type='hidden' name='return_id' value='".$focus->id."'>\n";
|
||||
$button .= "<input type='hidden' name='action'>\n";
|
||||
$button .= "<input title='".$app_strings['LBL_NEW_BUTTON_TITLE']
|
||||
."' accessKey='".$app_strings['LBL_NEW_BUTTON_KEY']
|
||||
."' class='button' onclick=\"this.form.action.value='EditView'\" type='submit' name='New' value=' "
|
||||
.$app_strings['LBL_NEW_BUTTON_LABEL']." '>\n";
|
||||
$button .= "<input title='".$app_strings['LBL_SELECT_BUTTON_TITLE']."' accessKey='"
|
||||
.$app_strings['LBL_SELECT_BUTTON_KEY']."' type='button' class='button' value=' "
|
||||
.$app_strings['LBL_SELECT_BUTTON_LABEL']
|
||||
." ' name='button' onclick='open_popup(\"EcmPriceBooks\", 600, 400, \"\", false, true, {$encoded_popup_request_data});'>\n";
|
||||
$button .= "</form>\n";
|
||||
|
||||
$ListView = new ListView();
|
||||
$ListView->initNewXTemplate( 'modules/EcmPriceBooks/SubPanelView.html',$current_module_strings);
|
||||
$ListView->xTemplateAssign("RETURN_URL", "&return_module=".$currentModule."&return_action=DetailView&return_id={$_REQUEST['record']}");
|
||||
$ListView->xTemplateAssign("EDIT_INLINE_PNG", get_image($image_path.'edit_inline', 'align="absmiddle" alt="'.$app_strings['LNK_EDIT'] .'" border="0"'));
|
||||
$ListView->xTemplateAssign("DELETE_INLINE_PNG", get_image($image_path.'delete_inline','align="absmiddle" alt="'.$app_strings['LNK_REMOVE'].'" border="0"'));
|
||||
|
||||
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
|
||||
$header_text = " <a href='index.php?action=index&module=DynamicLayout&from_action=SubPanelView&from_module=EcmPriceBooks&record="
|
||||
.$_REQUEST['record']."'>"
|
||||
.get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")
|
||||
."</a>";
|
||||
}
|
||||
$ListView->setHeaderTitle($current_module_strings['LBL_MODULE_NAME'] . $header_text );
|
||||
$ListView->setHeaderText($button);
|
||||
$ListView->processListView($focus_list, "main", "ECMPRICEBOOK");
|
||||
?>
|
||||
23
modules/EcmPriceBooks2/UpdatePriceBook.php
Executable file
23
modules/EcmPriceBooks2/UpdatePriceBook.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?
|
||||
$result = $GLOBALS['db']->query("select name,id from ecmpricebooks where deleted='0'");
|
||||
|
||||
$ile=mysql_num_rows($result);
|
||||
for($i=0;$i<$ile;$i++)
|
||||
{
|
||||
if($_REQUEST['check'][$i])
|
||||
{
|
||||
$w=$GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_REQUEST['pricebook_id'][$i]."' and ecmproduct_id='".$_REQUEST['product_id']."'");
|
||||
if(mysql_num_rows($w)==0)
|
||||
{
|
||||
$GLOBALS['db']->query("insert into ecmpricebooks_ecmproducts(id,ecmpricebook_id,ecmproduct_id,deleted,price,created_by,date_entered,date_modified,modified_user_id) values('".create_guid()."','".$_REQUEST['pricebook_id'][$i]."','".$_REQUEST['product_id']."','0','".$_REQUEST['list_price_'.$_REQUEST['pricebook_id'][$i]]."','".$_SESSION['authenticated_user_id']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','".$_SESSION['authenticated_user_id']."')");
|
||||
}
|
||||
else
|
||||
{
|
||||
$z="update ecmpricebooks_ecmproducts set price='".$_REQUEST['list_price_'.$_REQUEST['pricebook_id'][$i]]."' where ecmpricebook_id='".$_REQUEST['pricebook_id'][$i]."' and ecmproduct_id='".$_REQUEST['product_id']."'";
|
||||
//print $z;
|
||||
$GLOBALS['db']->query($z);
|
||||
}
|
||||
}
|
||||
}
|
||||
header("Location: index.php?module=".$_REQUEST['return_module']."&action=".$_REQUEST['return_action']."&record=".$_REQUEST['return_id']);
|
||||
?>
|
||||
4
modules/EcmPriceBooks2/XLS.php
Executable file
4
modules/EcmPriceBooks2/XLS.php
Executable file
@@ -0,0 +1,4 @@
|
||||
<?
|
||||
header("Content-type: application/vnd.ms-excel");
|
||||
header("Content-Disposition: inline; filename=\"../../cache/upload/".$_REQUEST['file']."\"");
|
||||
?>
|
||||
110
modules/EcmPriceBooks2/categoryOrder.php
Executable file
110
modules/EcmPriceBooks2/categoryOrder.php
Executable file
@@ -0,0 +1,110 @@
|
||||
<?
|
||||
if($_REQUEST['reset']==1){
|
||||
$GLOBALS['db']->query("delete from ecmpricebooks_ecmproducts_categories_sort where ecmpricebook_id='".$_REQUEST['record']."'");
|
||||
header("Location: index.php?module=EcmPriceBooks&action=categoryOrder&record=".$_REQUEST['record']);
|
||||
}
|
||||
if($_REQUEST['save']){
|
||||
$b=explode("|",$_REQUEST['sort_order']);
|
||||
$i=1;
|
||||
foreach($b as $box){
|
||||
if(strlen($box)>=1 && $box!="" && $box!=" ")$boxy[]=$box;
|
||||
}
|
||||
$GLOBALS['db']->query("delete from ecmpricebooks_ecmproducts_categories_sort where ecmpricebook_id='".$_REQUEST['record']."'");
|
||||
for($i=1;$i<=count($boxy);$i++){
|
||||
|
||||
$z="insert into ecmpricebooks_ecmproducts_categories_sort set id='".create_guid()."',position='".$i."',ecmpricebook_id='".$_REQUEST['record']."',category_id='".$boxy[$i-1]."'";
|
||||
$GLOBALS['db']->query($z);
|
||||
}
|
||||
header("Location: index.php?module=EcmPriceBooks&action=productsOrder&record=".$_REQUEST['record']);
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript" src="modules/EcmPriceBooks/moo1.2.js"></script>
|
||||
<script language="javascript">
|
||||
/* when the DOM is ready */
|
||||
window.addEvent('domready', function() {
|
||||
|
||||
/* create sortables */
|
||||
var sb = new Sortables('sortable-list', {
|
||||
/* set options */
|
||||
clone:true,
|
||||
revert: true,
|
||||
/* initialization stuff here */
|
||||
initialize: function() {
|
||||
|
||||
},
|
||||
/* once an item is selected */
|
||||
onStart: function(el) {
|
||||
el.setStyle('background','#add8e6');
|
||||
},
|
||||
/* when a drag is complete */
|
||||
onComplete: function(el) {
|
||||
el.setStyle('background','#ddd');
|
||||
//build a string of the order
|
||||
var sort_order = '';
|
||||
$$('#sortable-list li').each(function(li) { sort_order = sort_order + li.get('alt') + '|'; });
|
||||
$('sort_order').value = sort_order;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
li.sortme {
|
||||
padding:2px 2px;
|
||||
font-size: 9px;
|
||||
color:#000;
|
||||
cursor:move;
|
||||
list-style:none;
|
||||
width:700px;
|
||||
background:#ddd;
|
||||
margin:10px 0;
|
||||
border:1px solid #999;
|
||||
}
|
||||
#sortable-list{
|
||||
clear: none;
|
||||
float: left;
|
||||
margin: 2px;
|
||||
padding: 4px;
|
||||
}
|
||||
</style>
|
||||
<table width='100%' cellpadding='0' cellspacing='0' border='0' class='moduleTitle'><tr><td valign='top'>
|
||||
</td><td width='100%'><h2>Set Categories Order:
|
||||
<?php
|
||||
$z="select name from ecmpricebooks where id='".$_REQUEST['record']."'";
|
||||
$w=$GLOBALS['db']->query($z);
|
||||
$r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
print " ".$r['name'];
|
||||
?>
|
||||
</h2></td>
|
||||
</tr></table>
|
||||
<form action="index.php?module=EcmPriceBooks&action=categoryOrder&record=<?php echo $_REQUEST['record'];?>" method="post">
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td style="padding-bottom: 2px;">
|
||||
<input type="submit" value="Save" name="save" class="button">
|
||||
<input type="button" value="Reset" name="reset" class="button" onclick="location.href='index.php?module=EcmPriceBooks&reset=1&action=categoryOrder&record=<?php echo $_REQUEST['record'];?>';">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
|
||||
<tr>
|
||||
<td class="dataLabel">
|
||||
<ul id="sortable-list">
|
||||
<?php
|
||||
if(mysql_num_rows($GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts_categories_sort where ecmpricebook_id='".$_REQUEST['record']."'"))==0)$z="select id from ecmproductcategories where deleted='0' order by name asc";
|
||||
else $z="select position,category_id as id from ecmpricebooks_ecmproducts_categories_sort where ecmpricebook_id='".$_REQUEST['record']."' order by position asc";
|
||||
$w=$GLOBALS['db']->query($z);
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name from ecmproductcategories where id='".$r['id']."'"));
|
||||
print '<li class="sortme" alt="'.$r['id'].'">'.$rr['name'].'</li>';
|
||||
$sort_order[] = $r['id'];
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<input type="hidden" name="sort_order" id="sort_order" value="<?php echo implode($sort_order,'|'); ?>" />
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
15
modules/EcmPriceBooks2/changeDM.php
Executable file
15
modules/EcmPriceBooks2/changeDM.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
if($_REQUEST['record']){
|
||||
if($GLOBALS['db']->query("update ecmproducts set date_modified='".date("Y-m-d H:i:s")."' where id='".$_REQUEST['record']."'"))echo "ok";
|
||||
else echo "false";
|
||||
}
|
||||
else{
|
||||
$w=$GLOBALS['db']->query("select p.date_modified,p.id,p.name,p.code from ecmpricebooks_ecmproducts as e inner join ecmproducts as p on p.id=e.ecmproduct_id where e.ecmpricebook_id='418fa92d-1f20-4a4f-bd78-4d6662e89059' and e.deleted='0' order by p.date_modified desc");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
echo '<a href="index.php?module=EcmPriceBooks&action=changeDM&record='.$r['id'].'">'.$r['date_modified'].' '.$r['code'].' '.$r['name'].'</a> ';
|
||||
//if($GLOBALS['db']->query("update ecmproducts set date_modified='".date("Y-m-d H:i:s")."' where id='".$r['id']."'"))echo "ok";
|
||||
//else echo "false";
|
||||
echo '<br>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
10
modules/EcmPriceBooks2/checkAllProducts.php
Executable file
10
modules/EcmPriceBooks2/checkAllProducts.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<?
|
||||
$result = $GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_REQUEST['pricebook_id']."'");
|
||||
$checkc='';
|
||||
$_SESSION['pricebook_check']=array();
|
||||
while($ro=$GLOBALS['db']->fetchByAssoc($result))
|
||||
{
|
||||
$_SESSION['pricebook_check'][$_REQUEST['pricebook_id']][$ro['id']]=$_GET['value'];
|
||||
}
|
||||
$_SESSION['pricebook_check'][$_REQUEST['pricebook_id']]['all']=$_GET['value'];
|
||||
?>
|
||||
4
modules/EcmPriceBooks2/checkProduct.php
Executable file
4
modules/EcmPriceBooks2/checkProduct.php
Executable file
@@ -0,0 +1,4 @@
|
||||
<?
|
||||
$_SESSION['pricebook_check'][$_REQUEST['pricebook_id']][$_GET['record']]=$_GET['value'];
|
||||
print $_GET['value'];
|
||||
?>
|
||||
43
modules/EcmPriceBooks2/createCatalogue.php
Executable file
43
modules/EcmPriceBooks2/createCatalogue.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
set_time_limit(99999);
|
||||
error_reporting(0);
|
||||
$bag1='modules/EcmProducts/bag1.png';
|
||||
$bag2='modules/EcmProducts/bag2.png';
|
||||
$_REQUEST['html']=1;
|
||||
$_GET['no_print']=1;
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="i.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="i.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="i.id='9999999999999999' and ";
|
||||
|
||||
$w=$GLOBALS['db']->query("select i.ecmproduct_id from ecmpricebooks_ecmproducts as i inner join ecmproducts as p on p.id=i.ecmproduct_id where ".$where." i.ecmpricebook_id='".$_REQUEST['record']."' and i.deleted='0' order by p.product_category_name asc,p.code asc");
|
||||
|
||||
include_once("include/html2fpdf/html2fpdf.php");
|
||||
include_once("modules/EcmProducts/productCard.php");
|
||||
$p=new HTML2FPDF();
|
||||
|
||||
$i=0;
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$i++;
|
||||
$id=$r['ecmproduct_id'];
|
||||
if($i%2>0)$p->AddPage();
|
||||
$p=printCatalogue($p,$id,$_REQUEST['language'],true,true,false);
|
||||
|
||||
}
|
||||
|
||||
$p->Output("Catalogue.pdf","D");
|
||||
?>
|
||||
6
modules/EcmPriceBooks2/deleteProductFromPriceBook.php
Executable file
6
modules/EcmPriceBooks2/deleteProductFromPriceBook.php
Executable file
@@ -0,0 +1,6 @@
|
||||
<?
|
||||
if($_REQUEST['id']){
|
||||
if($GLOBALS['db']->query("update ecmpricebooks_ecmproducts set date_modified='".date("Y-m-d H:i:s")."',modified_user_id='".$_SESSION['authenticated_user_id']."',deleted='1' where id='".$_REQUEST['id']."'"))print "ok";
|
||||
else print "no";
|
||||
}
|
||||
?>
|
||||
7
modules/EcmPriceBooks2/deleteProducts.php
Executable file
7
modules/EcmPriceBooks2/deleteProducts.php
Executable file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
$e=explode("|",$_REQUEST['keys']);
|
||||
foreach($e as $ee){
|
||||
$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set date_modified='".date("Y-m-d H:i:s")."',modified_user_id='".$_SESSION['authenticated_user_id']."',deleted='1' where id='".$ee."' and ecmpricebook_id='".$_REQUEST['return_id']."'");
|
||||
}
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_REQUEST['return_id']."&tab=items");
|
||||
?>
|
||||
425
modules/EcmPriceBooks2/excel.php
Executable file
425
modules/EcmPriceBooks2/excel.php
Executable file
@@ -0,0 +1,425 @@
|
||||
<?php
|
||||
/* Class for use with PHP4 scripts only*/
|
||||
|
||||
|
||||
/*
|
||||
* This is an Excel class to create,load,read,write,save and use some of the internal
|
||||
* functionalities of workbooks and sheets.
|
||||
* Tested with Windows 98 - MS Office 2000
|
||||
* Apache 1.3.9 PHP4.02 Running as CGI
|
||||
* (c) Alain M. Samoun 09/2000.
|
||||
* alain@sonic.net
|
||||
* Gnu GPL code (see www.fsf.org for more information).
|
||||
*/
|
||||
|
||||
|
||||
class Excel {
|
||||
|
||||
/* variables */
|
||||
|
||||
var $ex;
|
||||
var $pathin;
|
||||
var $pathout;
|
||||
var $workbook;
|
||||
var $sheet;
|
||||
var $visible;
|
||||
var $fformatin;
|
||||
var $fformatout;
|
||||
var $cell;
|
||||
var $rangesens;
|
||||
var $range;
|
||||
var $ext;
|
||||
var $oext;
|
||||
|
||||
|
||||
/* Constructor */
|
||||
|
||||
function excel()
|
||||
{
|
||||
#Instantiate Excel
|
||||
//$this->ex = new COM("Excel.sheet") or Die ("Did not instantiate Excel");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
function XL($workbook,$pathin="",$sheet="sheet1")
|
||||
{
|
||||
|
||||
if ($workbook != "")
|
||||
{
|
||||
#Load the workbook
|
||||
$wkb = $this->ex->application->Workbooks->Open($pathin.$workbook) or Die ("Did not open $pathin $workbook");
|
||||
|
||||
}else{
|
||||
#New workbook
|
||||
$wkb = $this->ex->application->Workbooks->Add or Die ("Unable to add a workbook");
|
||||
}
|
||||
|
||||
if ($sheet != "")
|
||||
{
|
||||
#Activate the sheet
|
||||
$sheets = $wkb->Worksheets($sheet) or Die ("Unable to activate $sheet");
|
||||
|
||||
}else{
|
||||
#new sheet
|
||||
$sheet = "sheet1" ;
|
||||
|
||||
}
|
||||
#Excel Won't prompt the user when replacing or closing workbooks
|
||||
#Comment the line below if you want Excel to prompt
|
||||
$this->ex->application->DisplayAlerts = "False";
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function readrange($sheet="sheet1",$range)
|
||||
{
|
||||
|
||||
#Read all the cells in the range to $result and return it
|
||||
unset ($result);
|
||||
|
||||
$range = trim($range);
|
||||
#Determine start and end of range
|
||||
$tokstart = strtok($range,":");
|
||||
$tokend = strtok(":");
|
||||
if ($tokend =="")
|
||||
{
|
||||
#Read one single cell
|
||||
$sheets = $this->ex->Application->Worksheets($sheet);
|
||||
$sheets->activate;
|
||||
#Select the cell
|
||||
$selcell = $sheets->Range($range);
|
||||
$selcell->activate;
|
||||
return $selcell->value;
|
||||
}
|
||||
#Read a range of cells
|
||||
#determine column and row numbers
|
||||
$sheets = $this->ex->Application->Worksheets($sheet);
|
||||
$sheets->activate;
|
||||
$rgstart = $sheets->range($tokstart);
|
||||
$colstart = $rgstart->column;
|
||||
$rowstart = $rgstart->row;
|
||||
$rgend = $sheets->range($tokend);
|
||||
$colend = $rgend->column;
|
||||
$rowend = $rgend->row;
|
||||
if ($colstart>$colend or $rowstart>$rowend)
|
||||
{
|
||||
Print ("Notation Error! Cell Column/Row should be increasing.");
|
||||
return;
|
||||
}
|
||||
#Now read each cell
|
||||
|
||||
if ($colstart == $colend)
|
||||
{
|
||||
#Read Vertically
|
||||
$j=0;
|
||||
For ($i= $rowstart; $i<=$rowend; $i++)
|
||||
{
|
||||
|
||||
$selcell = $sheets->cells($i,$colstart);
|
||||
$selcell->activate;
|
||||
$result[$j] = $selcell->value;
|
||||
$j++;
|
||||
}
|
||||
}else
|
||||
{
|
||||
#Read horizontally
|
||||
$j=0;
|
||||
For ($i= $colstart; $i<=$colend; $i++)
|
||||
{
|
||||
|
||||
$selcell = $sheets->cells($rowstart,$i);
|
||||
$selcell->activate;
|
||||
$result[$j] = $selcell->value;
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function writerange($sheet="sheet1",$range,$value)
|
||||
{
|
||||
|
||||
#Fill up all the cells in the range with array
|
||||
|
||||
$range = trim($range);
|
||||
#Determine start and end of range
|
||||
$tokstart = strtok($range,":");
|
||||
$tokend = strtok(":");
|
||||
if ($tokend =="")
|
||||
{
|
||||
|
||||
# Write to a single cell in the active sheet
|
||||
$cell = trim($range);
|
||||
#Select the sheet
|
||||
$sheets = $this->ex->Application->Worksheets($sheet);
|
||||
$sheets->activate;
|
||||
#Select the cell
|
||||
$selcell = $sheets->Range($cell);
|
||||
$selcell->activate;
|
||||
$selcell->value = $value;
|
||||
return;
|
||||
}
|
||||
|
||||
#determine column and row numbers
|
||||
$sheets = $this->ex->Application->Worksheets($sheet);
|
||||
$sheets->activate;
|
||||
$rgstart = $sheets->range($tokstart);
|
||||
$colstart = $rgstart->column;
|
||||
$rowstart = $rgstart->row;
|
||||
$rgend = $sheets->range($tokend);
|
||||
$colend = $rgend->column;
|
||||
$rowend = $rgend->row;
|
||||
if ($colstart>$colend or $rowstart>$rowend)
|
||||
{
|
||||
Print ("Notation Error! Cell Column/Row should be increasing.");
|
||||
return;
|
||||
}
|
||||
#Now write each cell
|
||||
|
||||
if ($colstart == $colend)
|
||||
{
|
||||
#write Vertically
|
||||
$j=0;
|
||||
For ($i= $rowstart; $i<=$rowend; $i++)
|
||||
{
|
||||
|
||||
$selcell = $sheets->cells($i,$colstart);
|
||||
$selcell->activate;
|
||||
$selcell->value = $value[$j];
|
||||
$j++;
|
||||
}
|
||||
}else
|
||||
{
|
||||
#Write horizontally
|
||||
$j=0;
|
||||
For ($i= $colstart; $i<=$colend; $i++)
|
||||
{
|
||||
|
||||
$selcell = $sheets->cells($rowstart,$i);
|
||||
$selcell->activate;
|
||||
$selcell->value = $value[$j];
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
function saveas($workbook,$pathout,$ext)
|
||||
{
|
||||
|
||||
|
||||
#First get the file format code for the extension $ext
|
||||
$code = $this->fileformater($ext);
|
||||
$basefile = strtok($workbook,".");
|
||||
$newworkbook = $basefile."."."$ext";
|
||||
|
||||
|
||||
#If no prompt and file exists it will be replaced.
|
||||
|
||||
|
||||
#Save the current workbook as new workbook
|
||||
#The following line will work for converting spreadsheets file to xls
|
||||
#but if the original is an excel file and the new file another format
|
||||
#then it may not work because limitations of excel.(See excel doc)
|
||||
|
||||
$this->ex->Application->ActiveWorkbook->SaveAS($pathout.$newworkbook,$code);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function fileformater($ext)
|
||||
{
|
||||
|
||||
switch(strtolower($ext))
|
||||
{
|
||||
|
||||
case "slk":
|
||||
return 2;
|
||||
break;
|
||||
|
||||
case "xlt":
|
||||
return -4143;
|
||||
break;
|
||||
|
||||
case "txt":
|
||||
return -4158;
|
||||
break;
|
||||
|
||||
case "csv":
|
||||
return 6;
|
||||
break;
|
||||
|
||||
case "xlw":
|
||||
return 35;
|
||||
break;
|
||||
|
||||
case "w4k":
|
||||
return 38;
|
||||
break;
|
||||
|
||||
case "wq1":
|
||||
return 34;
|
||||
break;
|
||||
|
||||
case "prn":
|
||||
return -4158;
|
||||
break;
|
||||
|
||||
case "dif":
|
||||
return 9;
|
||||
break;
|
||||
|
||||
case "xla":
|
||||
return -4143;
|
||||
break;
|
||||
|
||||
case "wk3":
|
||||
return 32;
|
||||
break;
|
||||
|
||||
case "xls":
|
||||
return -4143;
|
||||
break;
|
||||
|
||||
case "htm":
|
||||
return 44;
|
||||
break;
|
||||
|
||||
case "wks":
|
||||
return 4;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -4143;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function XLTranslate($pathin,$pathout,$oext,$ext,$kill=0)
|
||||
{
|
||||
|
||||
#This function will translate automatically all spreadsheets files, with the
|
||||
#$oext extension, in the $pathin directory, to another spreadsheet file,
|
||||
#with the $ext extension, to the $pathout directory.
|
||||
#It will erase the original file if $kill switch = 1.
|
||||
#Limitations: Will work always when translating none excel files to
|
||||
#excel files(Extension=xl*) and with the translation xls->htm . It will
|
||||
#not generally work when translating excel files to other formats because
|
||||
#the questions asked by the excel program stop the script.
|
||||
|
||||
#Get all files in the source directory $pathin to the $filelist array
|
||||
chdir($pathin);
|
||||
$dir=dir (".");
|
||||
$i=1;
|
||||
while($file=$dir->read())
|
||||
{
|
||||
$filelist [$i] = $file;
|
||||
$i++;
|
||||
}
|
||||
$dir->close;
|
||||
|
||||
#Translate each file, with the original extension $oext, in the $filelist
|
||||
#to the needed extension $ext.
|
||||
|
||||
for ($i=1;$i<= sizeof($filelist); $i++)
|
||||
{
|
||||
|
||||
$file = $filelist[$i];
|
||||
|
||||
$basefile = strtok($file,".");
|
||||
$extension = strtok(".");
|
||||
|
||||
|
||||
if (strtolower($extension) == strtolower($oext))
|
||||
{
|
||||
echo "<BR> $file";
|
||||
$this->XL($file,$pathin,$sheet="");
|
||||
$this->saveas($file,$pathout,$ext,"");
|
||||
#Erase the original file if $kill=1
|
||||
if ($kill)
|
||||
{
|
||||
chmod ($file,0777);
|
||||
unlink ($pathin.$file);
|
||||
}
|
||||
#Close the new workbook
|
||||
$this->closeXL();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function closexl()
|
||||
{
|
||||
|
||||
#Close active workbook without prompt from Excel
|
||||
|
||||
$this->ex->application->ActiveWorkbook->Close("False");
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
function runfunction($funct,$arrayparam)
|
||||
{
|
||||
#Run and return value of an excel function
|
||||
|
||||
$params = implode(",",$arrayparam);
|
||||
|
||||
eval ("\$result = \$this->ex->application->$funct($params);");
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
Function runmacro($workbook,$macroname)
|
||||
{
|
||||
$this->ex->application->Run("$workbook!$macroname");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Function createhyperlink($sheet="sheet1",$cell,$hyperl)
|
||||
{
|
||||
#Not working as 9/2/00 4:57PM
|
||||
print "<br>link = $hyperl <br>";
|
||||
$sheets = $this->ex->Application->Worksheets($sheet);
|
||||
$sheets->activate;
|
||||
#Select the cell
|
||||
$selcell = $sheets->Range($cell);
|
||||
|
||||
$sheets->hyperlinks->add($selcell,$hyperl);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
function calculate($sheet="sheet1")
|
||||
{
|
||||
#Calculate (update) the current sheet
|
||||
$sheets = $this->ex->Application->Worksheets($sheet); #Select the sheet
|
||||
$sheets->activate;
|
||||
$sheets->Calculate;
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} /* end of Excel class */
|
||||
|
||||
?>
|
||||
97
modules/EcmPriceBooks2/field_arrays.php
Executable file
97
modules/EcmPriceBooks2/field_arrays.php
Executable file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
$fields_array['EcmPriceBook'] = array (
|
||||
'column_fields' => Array(
|
||||
"id",
|
||||
"name",
|
||||
"date_entered",
|
||||
"date_modified",
|
||||
"modified_user_id",
|
||||
"assigned_user_id",
|
||||
"created_by",
|
||||
//NEW COLUMN FIELDS
|
||||
"active",
|
||||
"description",
|
||||
"exchange_rate_name",
|
||||
"exchange_rate_id",
|
||||
"account_name",
|
||||
"account_id",
|
||||
"lead_name",
|
||||
"lead_id",
|
||||
"price",
|
||||
"ecmlanguage",
|
||||
"currency_value",
|
||||
"archived"
|
||||
),
|
||||
|
||||
'list_fields' => Array(
|
||||
'id',
|
||||
'name',
|
||||
'assigned_user_name',
|
||||
'assigned_user_id',
|
||||
//NEW LIST_FIELDS
|
||||
'active',
|
||||
'description',
|
||||
'exchange_rate_name',
|
||||
'exchange_rate_id',
|
||||
'account_name',
|
||||
'account_id',
|
||||
'lead_name',
|
||||
'lead_id',
|
||||
'price',
|
||||
'ecmlanguage',
|
||||
'currency_value',
|
||||
'archived',
|
||||
),
|
||||
'required_fields' => array(
|
||||
'name'=>1
|
||||
),
|
||||
);
|
||||
?>
|
||||
25
modules/EcmPriceBooks2/getPriceBooks.php
Executable file
25
modules/EcmPriceBooks2/getPriceBooks.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?
|
||||
global $db;
|
||||
//if($_REQUEST['account_id'])$arr[]="(account_id='".$_REQUEST['account_id']."')";
|
||||
//if($_REQUEST['exchange_rate_id'])$arr[]="exchange_rate_id like '".$_REQUEST['exchange_rate_id']."'";
|
||||
//$where="where ".@implode(" and ",$arr);
|
||||
|
||||
$z="select id,name from ecmpricebooks ".$where." order by name asc";
|
||||
//print $z;
|
||||
$result = $db->query($z);
|
||||
$pbs='<select id="pricebook_id" name="pricebook_id"><option value="">standard</option>';
|
||||
$i=0;
|
||||
$stop=0;
|
||||
while(($row=$db->fetchByAssoc($result))!=null)
|
||||
{
|
||||
$pbs.='<option value="'.$row['id'].'"';
|
||||
if($_GET['pricebook_id']==$row['id'] && $stop==0){
|
||||
$pbs.=' selected';
|
||||
$stop=1;
|
||||
}
|
||||
$pbs.='>'.$row['name'].'</option>';
|
||||
$i++;
|
||||
}
|
||||
$pbs.='</select>';
|
||||
print $pbs;
|
||||
?>
|
||||
12
modules/EcmPriceBooks2/importpricebooks.php
Executable file
12
modules/EcmPriceBooks2/importpricebooks.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?
|
||||
$GLOBALS['db']->query("truncate table ecmpricebooks");
|
||||
$w=$GLOBALS['db']->query("select pricebook.* from pricebook inner join crmentity on crmentity.crmid=pricebook.pricebookid where crmentity.deleted='0'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)) {
|
||||
if($r['currency']==1)$er="bea4e045-359e-1d69-20af-48f2f98b0ca1";
|
||||
if($r['currency']==2)$er="def7187b-9f88-4e6f-a513-48f2f98d01ba";
|
||||
if($r['currency']==3)$er="-99";
|
||||
if($GLOBALS['db']->query("insert into ecmpricebooks values('".$r['pricebookid']."','".$r['bookname']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','1','1','1','0','".$r['active']."','".$r['description']."','','".$er."','','','','','')"))print "ok";
|
||||
else print "no";
|
||||
print "<br>";
|
||||
}
|
||||
?>
|
||||
9
modules/EcmPriceBooks2/importproductrels.php
Executable file
9
modules/EcmPriceBooks2/importproductrels.php
Executable file
@@ -0,0 +1,9 @@
|
||||
<?
|
||||
$GLOBALS['db']->query("truncate table ecmpricebooks_ecmproducts");
|
||||
$w=$GLOBALS['db']->query("select * from pricebookproductrel");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)) {
|
||||
if($GLOBALS['db']->query("insert into ecmpricebooks_ecmproducts values('".create_guid()."','".$r['pricebookid']."','".$r['productid']."','0','".$r['listprice']."','1','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','1')"))print "ok";
|
||||
else print "no";
|
||||
print "<br>";
|
||||
}
|
||||
?>
|
||||
6
modules/EcmPriceBooks2/index.php
Executable file
6
modules/EcmPriceBooks2/index.php
Executable file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
global $current_user;
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
require_once('modules/EcmPriceBooks/ListView.php');
|
||||
|
||||
?>
|
||||
178
modules/EcmPriceBooks2/language/en_us.lang.php
Executable file
178
modules/EcmPriceBooks2/language/en_us.lang.php
Executable file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$mod_strings = array (
|
||||
//added 02.12.2009
|
||||
'LBL_PRODUCT_CARD' => 'Create Catalogue',
|
||||
'LBL_ARCHIVED'=>'Archived',
|
||||
'LBL_CURRENCY_VALUE'=>'Currency value',
|
||||
//added 01.09.2009
|
||||
'LBL_CV_EDIT'=>'Edit',
|
||||
'LBL_CV_DELETE'=>'Delete',
|
||||
'LBL_CV_CREATE'=>'Create Custom View',
|
||||
'LBL_CV_QUESTION'=>'Are you sure?',
|
||||
'LBL_ADD_PRODUCTS_TO_PRICEBOOK'=>'Add Products To Pricebook',
|
||||
//added 09.03.2009
|
||||
'LBL_ECMLANGUAGE'=>'Language',
|
||||
//added 19.02.2009
|
||||
'LBL_NO_ON_THIS_PRICEBOOK' => 'No on this Price Book',
|
||||
'LBL_LIST_PRICE_NAME' => 'Price',
|
||||
// added 19.01.2009
|
||||
'LBL_REMARKS_PL'=>'Remarks PL',
|
||||
'LBL_REMARKS_EN'=>'Remarks EN',
|
||||
'LBL_REMARKS_DE'=>'Remarks DE',
|
||||
|
||||
// added
|
||||
'LBL_RECIPIENT_CODE'=>'Recipient Code',
|
||||
// added 17.12.2008
|
||||
'LBL_ASCENDING'=>'Ascending',
|
||||
'LBL_DESCENDING'=>'Descending',
|
||||
'LBL_QUESTION_DELETE'=>'Are You sure to delete this record?',
|
||||
'LBL_UNIT_PRICE'=>'Unit Price',
|
||||
'LBL_MARGIN'=>'Margin',
|
||||
'LBL_LIST_PRICE_PRICEBOOK'=>'List Price',
|
||||
// added 12.12.2008
|
||||
'LBL_MARGIN'=>'Margin',
|
||||
'LBL_LIST_PRICE_ADD'=>'List Price',
|
||||
//added
|
||||
'LBL_DETAILS'=>'Details',
|
||||
'LBL_ITEMS'=>'Items',
|
||||
'LBL_PREVIEWPDF'=>'Preview PDF',
|
||||
'LBL_PREVIEWXLS'=>'Preview XLS',
|
||||
'LBL_EMAIL'=>'Email',
|
||||
'LBL_ACCOUNT_NAME'=>'Account name',
|
||||
'LBL_LEAD_NAME'=>'Lead name',
|
||||
'LBL_EDIT_PRICE'=>'Edit price',
|
||||
'LBL_INDEX'=>'Index',
|
||||
'LBL_PURCHASE_PRICE'=>'Purchase price',
|
||||
'LBL_LIST_PRICE'=>'List price',
|
||||
'LBL_MANUFACTURER'=>'Manufacturer',
|
||||
'LBL_ALL'=>'All',
|
||||
'LBL_PRODUCT_CATEGORY'=>'Product category',
|
||||
'LBL_PRODUCT_NAME'=>'Product name',
|
||||
'LBL_PRICEBOOK_NAME'=>'Price Book name',
|
||||
'LBL_UPDATE'=>'Update',
|
||||
|
||||
'LBL_LIST_PRICE' => 'Price',
|
||||
'LBL_ACCOUNT_NAME' => 'Account',
|
||||
// FOR SYSTEM USE
|
||||
'LBL_MODULE_NAME' => 'Price Books',
|
||||
'LBL_MODULE_TITLE' => 'Price Books: Home',
|
||||
'LBL_MODULE_ID' => 'Price Books',
|
||||
'LBL_SEARCH_FORM_TITLE' => 'Price Books Search',
|
||||
'LBL_LIST_FORM_TITLE' => 'Price Books List',
|
||||
'LBL_NEW_FORM_TITLE' => 'New Price Books',
|
||||
'LBL_ECMPRICEBOOKS' => 'Price Books:',
|
||||
'LBL_ECMPRICEBOOKS_SUBJECT' => 'Price Books Subject:',
|
||||
'LBL_SYSTEM_ID' => 'System ID',
|
||||
|
||||
// FOR LIST VIEW
|
||||
'LBL_LIST_NAME' => 'Name',
|
||||
'LBL_LIST_SUBJECT' => 'Subject',
|
||||
'LBL_LIST_LAST_MODIFIED' => 'Last Modified',
|
||||
'LBL_LIST_MY_ECMPRICEBOOKS' => 'My Assigned Price Books',
|
||||
'LBL_LIST_ASSIGNED_TO_NAME' => 'Assigned User',
|
||||
'LBL_LIST_ACTIVE' => 'Product active',
|
||||
'LBL_LIST_DESCRIPTION' => 'Description',
|
||||
'LBL_LIST_EXCHANGE_RATE_NAME' => 'Exchange rate',
|
||||
'LBL_LIST_EXCHANGE_RATE_ID' => 'Exchange rate',
|
||||
|
||||
// FOR NOTIFICATION POPUPS
|
||||
'NTC_DELETE_CONFIRMATION' => 'Are you sure you want to remove this ecmpricebook from this Price Book?',
|
||||
'NTC_REMOVE_INVITEE' => 'Are you sure you want to remove this contact from the Price Book?',
|
||||
'NTC_REMOVE_ACCOUNT_CONFIRMATION' => 'Are you sure you want to remove this ecmpricebook from this account?',
|
||||
'ERR_DELETE_RECORD' => 'A record number must be specified to delete the ecmpricebook.',
|
||||
|
||||
// FOR DEFAULT FIELDS
|
||||
'LBL_NAME' => 'Name:',
|
||||
'LBL_SUBJECT' => 'Name:',
|
||||
'LBL_CREATED_BY' => 'Created by:',
|
||||
'LBL_CREATED' => 'Created by:',
|
||||
'LBL_ASSIGNED_TO' => 'Assigned to:',
|
||||
'LBL_ASSIGNED_USER_ID' => 'Assigned To:',
|
||||
'LBL_DATE_ENTERED' => 'Date Created:',
|
||||
'LBL_DATE_CREATED' => 'Create Date:',
|
||||
'LBL_DATE_MODIFIED' => 'Last Modified',
|
||||
'LBL_MODIFIED_BY' => 'Last Modified by:',
|
||||
'LBL_MODIFIED' => 'Modified by:',
|
||||
'LBL_DATE_LAST_MODIFIED' => 'Modify Date:',
|
||||
|
||||
// FOR NEW FIELDS
|
||||
'LBL_ACTIVE' => 'Active',
|
||||
'LBL_DESCRIPTION' => 'Description',
|
||||
'LBL_EXCHANGE_RATE_NAME' => 'Exchange rate',
|
||||
'LBL_EXCHANGE_RATE_ID' => 'Exchange rate',
|
||||
|
||||
// FOR GROUPS
|
||||
'LBL_GROUP_MASTER' => 'PRICEBOOK INFORMATION',
|
||||
'LBL_GROUP_ACTIVE' => '',
|
||||
'LBL_GROUP_DESCRIPTION' => '',
|
||||
'LBL_GROUP_EXCHANGE_RATE_NAME' => '',
|
||||
'LBL_GROUP_EXCHANGE_RATE_ID' => '',
|
||||
// FOR SUBPANELS
|
||||
'LBL_ECMPRICEBOOKS_SUBPANEL_TITLE' => 'Price Books',
|
||||
'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Activities',
|
||||
'LBL_HISTORY_SUBPANEL_TITLE' => 'History',
|
||||
'LBL_ECMPRICEBOOKS' => 'Price Books',
|
||||
|
||||
// FOR MENU LABELS
|
||||
'LNK_NEW_ECMPRICEBOOKS' => 'Create Price Book',
|
||||
'LNK_LIST_ECMPRICEBOOK' => 'Price Books List',
|
||||
|
||||
// FOR MENU LINKS
|
||||
'LNK_NEW_ECMPRICEBOOK' => 'Create Price Books',
|
||||
'LNK_ECMPRICEBOOKS_LIST' => 'Price Books',
|
||||
'LNK_ECMPRICEBOOKS_REPORTS' => 'Price Books Reports',
|
||||
// FOR ADDITIONAL MENUS
|
||||
|
||||
// FOR DASHLETS
|
||||
'LBL_LIST_ECMPRICEBOOKS' => 'Price Books',
|
||||
);
|
||||
?>
|
||||
170
modules/EcmPriceBooks2/language/pl_pl.lang.php
Executable file
170
modules/EcmPriceBooks2/language/pl_pl.lang.php
Executable file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
if (!defined('sugarEntry') || !sugarEntry)
|
||||
die('Not A Valid Entry Point');
|
||||
/* * ***************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
* ****************************************************************************** */
|
||||
|
||||
$mod_strings = array(
|
||||
//added 01.09.2009
|
||||
'LBL_PRODUCT_CARD' => 'Generuj Katalog',
|
||||
'LBL_CV_EDIT' => 'Edytuj',
|
||||
'LBL_CV_DELETE' => 'Usuń',
|
||||
'LBL_CV_CREATE' => 'Utwórz Widok',
|
||||
'LBL_CV_QUESTION' => 'Na pewno?',
|
||||
'LBL_ADD_PRODUCTS_TO_PRICEBOOK' => 'Dodaj Produkty do Cennika',
|
||||
//added 09.03.2009
|
||||
'LBL_ECMLANGUAGE' => 'Jezyk',
|
||||
//added 19.02.2009
|
||||
'LBL_NO_ON_THIS_PRICEBOOK' => 'Nie na tym cenniku',
|
||||
'LBL_LIST_PRICE_NAME' => 'Cena',
|
||||
'LBL_CURRENCY_VALUE' => 'Cena',
|
||||
// added 19.01.2009
|
||||
'LBL_REMARKS_PL' => 'Uwagi PL',
|
||||
'LBL_REMARKS_EN' => 'Uwagi EN',
|
||||
'LBL_REMARKS_DE' => 'Uwagi DE',
|
||||
// added
|
||||
'LBL_RECIPIENT_CODE' => 'Kod Odbiorcy',
|
||||
// added 17.12.2008
|
||||
'LBL_ASCENDING' => 'Rosnaco',
|
||||
'LBL_DESCENDING' => 'Malejaco',
|
||||
'LBL_QUESTION_DELETE' => 'Jestes pewny, ze chcesz usunac ten rekord?',
|
||||
'LBL_UNIT_PRICE' => 'Cena Zakupu',
|
||||
'LBL_MARGIN' => 'Marza',
|
||||
'LBL_LIST_PRICE_PRICEBOOK' => 'Cena na Cenniku',
|
||||
// added 12.12.2008
|
||||
'LBL_MARGIN' => 'Marza',
|
||||
'LBL_LIST_PRICE_ADD' => 'Cena na Cenniku',
|
||||
//added
|
||||
'LBL_DETAILS' => 'Szczególy',
|
||||
'LBL_ITEMS' => 'Produkty',
|
||||
'LBL_PREVIEWPDF' => 'Podglad PDF',
|
||||
'LBL_PREVIEWXLS' => 'Podglad XLS',
|
||||
'LBL_EMAIL' => 'Email',
|
||||
'LBL_ACCOUNT_NAME' => 'Nazwa Firmy',
|
||||
'LBL_LEAD_NAME' => 'Wizytówka',
|
||||
'LBL_EDIT_PRICE' => 'Edytuj Cene',
|
||||
'LBL_INDEX' => 'Indeks',
|
||||
'LBL_PURCHASE_PRICE' => 'Cena Zakupu',
|
||||
'LBL_LIST_PRICE' => 'Cena na Cenniku',
|
||||
'LBL_MANUFACTURER' => 'Wytwórca',
|
||||
'LBL_ALL' => 'Wszystkie',
|
||||
'LBL_PRODUCT_CATEGORY' => 'Kategoria',
|
||||
'LBL_PRODUCT_NAME' => 'Nazwa Produktu',
|
||||
'LBL_PRICEBOOK_NAME' => 'Nazwa Cennika',
|
||||
'LBL_UPDATE' => 'Uaktualnij',
|
||||
'LBL_LIST_PRICE' => 'Cena',
|
||||
'LBL_ACCOUNT_NAME' => 'Firma',
|
||||
// FOR SYSTEM USE
|
||||
'LBL_MODULE_NAME' => 'Cenniki',
|
||||
'LBL_MODULE_TITLE' => 'Cenniki: Strona Glówna',
|
||||
'LBL_MODULE_ID' => 'Cenniki',
|
||||
'LBL_SEARCH_FORM_TITLE' => 'Wyszukaj',
|
||||
'LBL_LIST_FORM_TITLE' => 'List Cenników',
|
||||
'LBL_NEW_FORM_TITLE' => 'Nowy Cennik',
|
||||
'LBL_ECMPRICEBOOKS' => 'Cenniki:',
|
||||
'LBL_ECMPRICEBOOKS_SUBJECT' => 'Tytul Cennika:',
|
||||
'LBL_SYSTEM_ID' => 'System ID',
|
||||
// FOR LIST VIEW
|
||||
'LBL_LIST_NAME' => 'Nazwa',
|
||||
'LBL_LIST_SUBJECT' => 'Tytul',
|
||||
'LBL_LIST_LAST_MODIFIED' => 'Ostatnio Modyfikowane',
|
||||
'LBL_LIST_MY_ECMPRICEBOOKS' => 'Moje Przypisane Cenniki',
|
||||
'LBL_LIST_ASSIGNED_TO_NAME' => 'Przypisany Uzytkownik',
|
||||
'LBL_LIST_ACTIVE' => 'Produkt Aktywny',
|
||||
'LBL_LIST_DESCRIPTION' => 'Opis',
|
||||
'LBL_LIST_EXCHANGE_RATE_NAME' => 'Waluta',
|
||||
'LBL_LIST_EXCHANGE_RATE_ID' => 'Waluta',
|
||||
'LBL_PRICE_DETAIL_NAME' => 'Cennik: Szczegóły',
|
||||
'LBL_PRICE_PRODUCT_NAME' => 'Cennik: Produkty',
|
||||
// FOR NOTIFICATION POPUPS
|
||||
'NTC_DELETE_CONFIRMATION' => 'Czy napewno chcesz usunac Cennik?',
|
||||
'NTC_REMOVE_INVITEE' => 'Czy napewno chcesz usunac kontakt z Cennika?',
|
||||
'NTC_REMOVE_ACCOUNT_CONFIRMATION' => 'Czy napewno chcesz usunac Cennik z Firmy?',
|
||||
'ERR_DELETE_RECORD' => 'Musisz podac numer rekordu aby usunac.',
|
||||
// FOR DEFAULT FIELDS
|
||||
'LBL_NAME' => 'Nazwa:',
|
||||
'LBL_SUBJECT' => 'Nazwa:',
|
||||
'LBL_CREATED_BY' => 'Utworzone przez:',
|
||||
'LBL_CREATED' => 'Utworzone przez:',
|
||||
'LBL_ASSIGNED_TO' => 'Przypisane do:',
|
||||
'LBL_ASSIGNED_USER_ID' => 'Przypisane do:',
|
||||
'LBL_DATE_ENTERED' => 'Data Utworzenia:',
|
||||
'LBL_DATE_CREATED' => 'Data Utworzenia:',
|
||||
'LBL_DATE_MODIFIED' => 'Ostatnio Modyfikowane',
|
||||
'LBL_MODIFIED_BY' => 'Ostatnio Modyfikowane przez:',
|
||||
'LBL_MODIFIED' => 'Modifikowane przez:',
|
||||
'LBL_DATE_LAST_MODIFIED' => 'Data Modyfikacji:',
|
||||
// FOR NEW FIELDS
|
||||
'LBL_ACTIVE' => 'Aktywne',
|
||||
'LBL_DESCRIPTION' => 'Opis',
|
||||
'LBL_EXCHANGE_RATE_NAME' => 'Waluta',
|
||||
'LBL_EXCHANGE_RATE_ID' => 'Waluta',
|
||||
// FOR GROUPS
|
||||
'LBL_GROUP_MASTER' => 'INFORMACJE O CENNIKU',
|
||||
'LBL_GROUP_ACTIVE' => '',
|
||||
'LBL_GROUP_DESCRIPTION' => '',
|
||||
'LBL_GROUP_EXCHANGE_RATE_NAME' => '',
|
||||
'LBL_GROUP_EXCHANGE_RATE_ID' => '',
|
||||
// FOR SUBPANELS
|
||||
'LBL_ECMPRICEBOOKS_SUBPANEL_TITLE' => 'Cenniki',
|
||||
'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Aktywnosci',
|
||||
'LBL_HISTORY_SUBPANEL_TITLE' => 'Historia',
|
||||
'LBL_ECMPRICEBOOKS' => 'Cenniki',
|
||||
// FOR MENU LABELS
|
||||
'LNK_NEW_ECMPRICEBOOKS' => 'Utwórz Cennik',
|
||||
'LNK_LIST_ECMPRICEBOOK' => 'Lista Cenników',
|
||||
// FOR MENU LINKS
|
||||
'LNK_NEW_ECMPRICEBOOK' => 'Utwórz Cennik',
|
||||
'LNK_ECMPRICEBOOKS_LIST' => 'Cenniki',
|
||||
'LNK_ECMPRICEBOOKS_REPORTS' => 'Raport Cenników',
|
||||
// FOR ADDITIONAL MENUS
|
||||
// FOR DASHLETS
|
||||
'LBL_LIST_ECMPRICEBOOKS' => 'Cenniki',
|
||||
);
|
||||
?>
|
||||
57
modules/EcmPriceBooks2/layout_defs.php
Executable file
57
modules/EcmPriceBooks2/layout_defs.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
$smarty->debugging = true;
|
||||
$smarty->debugging_ctrl=($_SERVER['SERVER_NAME']=='localhost:8080')?'URL':'NONE';
|
||||
$layout_defs['EcmPriceBooks'] = array(
|
||||
//LIST OF WHAT SUBPANELS TO SHOW IN THE DETAILVIEW
|
||||
'subpanel_setup' => array(
|
||||
),
|
||||
);
|
||||
?>
|
||||
60
modules/EcmPriceBooks2/metadata/SearchFields.php
Executable file
60
modules/EcmPriceBooks2/metadata/SearchFields.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
$searchFields['EcmPriceBooks'] =
|
||||
array (
|
||||
'name' => array('query_type' => 'default'),
|
||||
'current_user_only'=> array('query_type' => 'default',
|
||||
'db_field' => array('assigned_user_id'),
|
||||
'my_items' => true
|
||||
),
|
||||
'archived'=>array('query_type'=>'default'),
|
||||
'assigned_user_id' => array('query_type' => 'default'),
|
||||
);
|
||||
?>
|
||||
84
modules/EcmPriceBooks2/metadata/additionalDetails.php
Executable file
84
modules/EcmPriceBooks2/metadata/additionalDetails.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/utils.php');
|
||||
|
||||
function additionalDetailsEcmPriceBook($fields) {
|
||||
static $mod_strings;
|
||||
global $app_strings;
|
||||
if(empty($mod_strings)) {
|
||||
global $current_language;
|
||||
$mod_strings = return_module_language($current_language, 'EcmPriceBooks');
|
||||
}
|
||||
|
||||
$overlib_string = '';
|
||||
|
||||
//BUILDER:START overlibstring
|
||||
if(!empty($fields['ACTIVE'])){
|
||||
$overlib_string .= '<b>'. $mod_strings['LBL_ACTIVE'] . '</b> <BR>' . substr($fields['ACTIVE'], 0, 300);
|
||||
if(strlen($fields['ACTIVE']) > 300) $overlib_string .= '...';
|
||||
$overlib_string .= '<br>';
|
||||
}
|
||||
if(!empty($fields['DESCRIPTION'])){
|
||||
$overlib_string .= '<b>'. $mod_strings['LBL_DESCRIPTION'] . '</b> <BR>' . substr($fields['DESCRIPTION'], 0, 300);
|
||||
if(strlen($fields['DESCRIPTION']) > 300) $overlib_string .= '...';
|
||||
$overlib_string .= '<br>';
|
||||
}
|
||||
//BUILDER:END overlibstring
|
||||
|
||||
return array(
|
||||
'fieldToAddTo' => 'NAME',
|
||||
'string' => $overlib_string,
|
||||
'editLink' => "index.php?action=EditView&module=EcmPriceBooks&return_module=EcmPriceBooks&record={$fields['ID']}",
|
||||
'viewLink' => "index.php?action=DetailView&module=EcmPriceBooks&return_module=EcmPriceBooks&record={$fields['ID']}");
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
58
modules/EcmPriceBooks2/metadata/editviewdefs.php
Executable file
58
modules/EcmPriceBooks2/metadata/editviewdefs.php
Executable file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
$viewdefs['EcmPriceBooks']['EditView'] = array(
|
||||
'templateMeta'=>array(
|
||||
'form' => array(
|
||||
'buttons'=>array('SAVE', 'CANCEL'),
|
||||
'enctype'=> 'multipart/form-data',
|
||||
),
|
||||
'maxColumns'=>'2',
|
||||
'widths'=>array(
|
||||
array('label'=>'10','field'=>'30'),
|
||||
array('label'=>'10','field'=>'30'),
|
||||
),
|
||||
),
|
||||
'panels'=>array(
|
||||
'DEFAULT'=>array(
|
||||
array('name','assigned_user_name'),
|
||||
array('active','exchange_rate_id'),
|
||||
array('account_name','lead_name'),
|
||||
array('description','currency_value'),
|
||||
array('ecmlanguage'),
|
||||
),
|
||||
),
|
||||
);
|
||||
?>
|
||||
98
modules/EcmPriceBooks2/metadata/listviewdefs.php
Executable file
98
modules/EcmPriceBooks2/metadata/listviewdefs.php
Executable file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$listViewDefs['EcmPriceBooks'] = array(
|
||||
'NAME' => array(
|
||||
'width' => '20',
|
||||
'label' => 'LBL_NAME',
|
||||
'default' => true,
|
||||
'link' => true),
|
||||
|
||||
'ACTIVE' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_ACTIVE'),
|
||||
'DESCRIPTION' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_DESCRIPTION'),
|
||||
'ACCOUNT_ID' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_ACCOUNT_ID'),
|
||||
'ACCOUNT_NAME' => array(
|
||||
'width' => '10',
|
||||
'link' => true,
|
||||
'module' => 'Accounts',
|
||||
'id' => 'ACCOUNT_ID',
|
||||
'label' => 'LBL_ACCOUNT_NAME',
|
||||
'default' => true),
|
||||
'EXCHANGE_RATE_NAME' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_EXCHANGE_RATE_NAME',
|
||||
'default' => true),
|
||||
|
||||
'DATE_MODIFIED' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_DATE_MODIFIED',
|
||||
'default' => true),
|
||||
'DATE_ENTERED' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_DATE_ENTERED',
|
||||
'default' => true),
|
||||
'CREATED_BY_NAME' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_CREATED'),
|
||||
'ASSIGNED_USER_NAME' => array(
|
||||
'width' => '2',
|
||||
'label' => 'LBL_LIST_ASSIGNED_USER',
|
||||
'default' => true),
|
||||
'MODIFIED_USER_NAME' => array(
|
||||
'width' => '2',
|
||||
'label' => 'LBL_MODIFIED')
|
||||
);
|
||||
?>
|
||||
62
modules/EcmPriceBooks2/metadata/popupdefs.php
Executable file
62
modules/EcmPriceBooks2/metadata/popupdefs.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$popupMeta = array(
|
||||
'moduleMain' => 'EcmPriceBook',
|
||||
'varName' => 'ECMPRICEBOOK',
|
||||
'orderBy' => 'ecmpricebooks.name',
|
||||
'whereClauses' => array(
|
||||
'name' => 'ecmpricebooks.name',
|
||||
'exchange_rate_id' => 'ecmpricebooks.exchange_rate_id',
|
||||
'account_id' => 'ecmpricebooks.account_id',
|
||||
),
|
||||
'searchInputs' => array('name', 'name')
|
||||
);
|
||||
?>
|
||||
67
modules/EcmPriceBooks2/metadata/searchdefs.php
Executable file
67
modules/EcmPriceBooks2/metadata/searchdefs.php
Executable file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*
|
||||
* Created on May 29, 2007
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - PHPeclipse - PHP - Code Templates
|
||||
*/
|
||||
$searchdefs['EcmPriceBooks'] = array(
|
||||
'templateMeta' => array(
|
||||
'maxColumns' => '3',
|
||||
'widths' => array('label' => '10', 'field' => '30'),
|
||||
),
|
||||
'layout' => array(
|
||||
'basic_search' => array(
|
||||
'name',
|
||||
array('name'=>'current_user_only', 'label'=>'LBL_CURRENT_USER_FILTER', 'type'=>'bool'),
|
||||
'description',
|
||||
'active',
|
||||
//array('name'=>'active','displayParams' => array('size' => 2)),
|
||||
//array('name'=>'pricebook_product_id','type'=>'hidden','value'=>$_REQUEST['pricebook_product_id']),
|
||||
|
||||
),
|
||||
'advanced_search' => array(
|
||||
'name',
|
||||
array('name' => 'assigned_user_id', 'type' => 'enum', 'label' => 'LBL_ASSIGNED_TO', 'function' => array('name' => 'get_user_array', 'params' => array(false))),
|
||||
'description',
|
||||
'active',
|
||||
//array('name'=>'active','displayParams' => array('size' => 2)),
|
||||
//array('name'=>'pricebook_product_id','type'=>'hidden','value'=>$_REQUEST['pricebook_product_id']),
|
||||
),
|
||||
),
|
||||
);
|
||||
?>
|
||||
76
modules/EcmPriceBooks2/metadata/studio.php
Executable file
76
modules/EcmPriceBooks2/metadata/studio.php
Executable file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$GLOBALS['studioDefs']['EcmPriceBooks'] = array(
|
||||
'LBL_DETAILVIEW'=>array(
|
||||
'template' => 'xtpl',
|
||||
'template_file' => 'modules/EcmPriceBooks/DetailView.html',
|
||||
'php_file' => 'modules/EcmPriceBooks/DetailView.php',
|
||||
'type' => 'DetailView',
|
||||
),
|
||||
'LBL_EDITVIEW'=>array(
|
||||
'template' => 'xtpl',
|
||||
'template_file' => 'modules/EcmPriceBooks/EditView.html',
|
||||
'php_file' => 'modules/EcmPriceBooks/EditView.php',
|
||||
'type' => 'EditView',
|
||||
),
|
||||
'LBL_LISTVIEW'=>array(
|
||||
'template' => 'listview',
|
||||
'meta_file' => 'modules/EcmPriceBooks/listviewdefs.php',
|
||||
'type' => 'ListView',
|
||||
),
|
||||
'LBL_SEARCHFORM'=>array(
|
||||
'template' => 'xtpl',
|
||||
'template_file' => 'modules/EcmPriceBooks/SearchForm.html',
|
||||
'php_file' => 'modules/EcmPriceBooks/ListView.php',
|
||||
'type' => 'SearchForm',
|
||||
),
|
||||
|
||||
);
|
||||
92
modules/EcmPriceBooks2/metadata/subpanels/ForProducts.php
Executable file
92
modules/EcmPriceBooks2/metadata/subpanels/ForProducts.php
Executable file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$subpanel_layout = array(
|
||||
'top_buttons' => array(
|
||||
array('widget_class' => 'SubPanelAddToChangeOnPriceBook'),
|
||||
),
|
||||
|
||||
'where' => '',
|
||||
|
||||
'fill_in_additional_fields' => true,
|
||||
|
||||
'list_fields' => array(
|
||||
'name'=>array(
|
||||
'vname' => 'LBL_LIST_NAME',
|
||||
'widget_class' => 'SubPanelDetailViewLink',
|
||||
'width' => '50%',
|
||||
),
|
||||
'date_entered'=>array(
|
||||
'vname' => 'LBL_LIST_PRICE',
|
||||
'widget_class' => 'GetPriceFromPriceBook',
|
||||
'width' => '20%',
|
||||
),
|
||||
'assigned_user_name' => array (
|
||||
'name' => 'assigned_user_name',
|
||||
'vname' => 'LBL_LIST_ASSIGNED_TO_NAME',
|
||||
),
|
||||
'active' => array (
|
||||
'name' => 'active',
|
||||
'vname' => 'LBL_ACTIVE',
|
||||
),
|
||||
'edit_button'=>array(
|
||||
'widget_class' => 'SubPanelEditButton',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'width' => '4%',
|
||||
),
|
||||
'remove_button'=>array(
|
||||
'widget_class' => 'SubPanelRemoveButton',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'width' => '5%',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
82
modules/EcmPriceBooks2/metadata/subpanels/default.php
Executable file
82
modules/EcmPriceBooks2/metadata/subpanels/default.php
Executable file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$subpanel_layout = array(
|
||||
'top_buttons' => array(
|
||||
array('widget_class' => 'SubPanelTopCreateButton'),
|
||||
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'EcmPriceBooks'),
|
||||
),
|
||||
|
||||
'where' => '',
|
||||
|
||||
'list_fields' => array(
|
||||
'name'=>array(
|
||||
'vname' => 'LBL_LIST_NAME',
|
||||
'widget_class' => 'SubPanelDetailViewLink',
|
||||
'width' => '50%',
|
||||
),
|
||||
'assigned_user_name' => array (
|
||||
'name' => 'assigned_user_name',
|
||||
'vname' => 'LBL_LIST_ASSIGNED_TO_NAME',
|
||||
),
|
||||
'edit_button'=>array(
|
||||
'widget_class' => 'SubPanelEditButton',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'width' => '4%',
|
||||
),
|
||||
'remove_button'=>array(
|
||||
'widget_class' => 'SubPanelRemoveButton',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'width' => '5%',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
118
modules/EcmPriceBooks2/productsOrder.php
Executable file
118
modules/EcmPriceBooks2/productsOrder.php
Executable file
@@ -0,0 +1,118 @@
|
||||
<?
|
||||
if($_REQUEST['reset']==1){
|
||||
$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set position=0 where ecmpricebook_id='".$_REQUEST['record']."'");
|
||||
header("Location: index.php?module=EcmPriceBooks&action=productsOrder&record=".$_REQUEST['record']);
|
||||
}
|
||||
if($_REQUEST['save']){
|
||||
$b=explode("|",$_REQUEST['sort_order']);
|
||||
$i=1;
|
||||
foreach($b as $box){
|
||||
if(strlen($box)>=1 && $box!="" && $box!=" ")$boxy[]=$box;
|
||||
}
|
||||
for($i=1;$i<=count($boxy);$i++){
|
||||
$z="update ecmpricebooks_ecmproducts set position='".$i."' where deleted='0' and ecmproduct_id='".$boxy[$i-1]."' and ecmpricebook_id='".$_REQUEST['record']."'";
|
||||
$GLOBALS['db']->query($z);
|
||||
}
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_REQUEST['record']);
|
||||
}
|
||||
$z="select id from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_REQUEST['record']."' and deleted='0'";
|
||||
$w=$GLOBALS['db']->query($z);
|
||||
$ile=mysql_num_rows($w);
|
||||
?>
|
||||
<script type="text/javascript" src="modules/EcmPriceBooks/moo1.2.js"></script>
|
||||
<script language="javascript">
|
||||
/* when the DOM is ready */
|
||||
window.addEvent('domready', function() {
|
||||
|
||||
/* create sortables */
|
||||
var sb = new Sortables('sortable-list', {
|
||||
/* set options */
|
||||
clone:true,
|
||||
revert: true,
|
||||
/* initialization stuff here */
|
||||
initialize: function() {
|
||||
|
||||
},
|
||||
/* once an item is selected */
|
||||
onStart: function(el) {
|
||||
el.setStyle('background','#add8e6');
|
||||
},
|
||||
/* when a drag is complete */
|
||||
onComplete: function(el) {
|
||||
el.setStyle('background','#ddd');
|
||||
//build a string of the order
|
||||
var sort_order = '';
|
||||
$$('#sortable-list li').each(function(li) { sort_order = sort_order + li.get('alt') + '|'; });
|
||||
$('sort_order').value = sort_order;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
li.sortme {
|
||||
padding:2px 2px;
|
||||
font-size: 9px;
|
||||
color:#000;
|
||||
cursor:move;
|
||||
list-style:none;
|
||||
width:700px;
|
||||
background:#ddd;
|
||||
margin:10px 0;
|
||||
border:1px solid #999;
|
||||
}
|
||||
#sortable-list{
|
||||
clear: none;
|
||||
float: left;
|
||||
margin: 2px;
|
||||
padding: 4px;
|
||||
}
|
||||
</style>
|
||||
<table width='100%' cellpadding='0' cellspacing='0' border='0' class='moduleTitle'><tr><td valign='top'>
|
||||
</td><td width='100%'><h2>Set Products Order:
|
||||
<?php
|
||||
$z="select name from ecmpricebooks where id='".$_REQUEST['record']."'";
|
||||
$w=$GLOBALS['db']->query($z);
|
||||
$r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
print " ".$r['name'];
|
||||
?>
|
||||
</h2></td>
|
||||
</tr></table>
|
||||
<form action="index.php?module=EcmPriceBooks&action=productsOrder&record=<?php echo $_REQUEST['record'];?>" method="post">
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td style="padding-bottom: 2px;">
|
||||
<input type="submit" value="Save" name="save" class="button">
|
||||
<input type="button" value="Reset" name="reset" class="button" onclick="location.href='index.php?module=EcmPriceBooks&reset=1&action=productsOrder&record=<?php echo $_REQUEST['record'];?>';">
|
||||
<input type="button" value="Categories Order" name="cat_order" class="button" onclick="location.href='index.php?module=EcmPriceBooks&action=categoryOrder&record=<?php echo $_REQUEST['record'];?>';">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
|
||||
<tr>
|
||||
<td class="dataLabel">
|
||||
<ul id="sortable-list">
|
||||
<?php
|
||||
if(mysql_num_rows($GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts_categories_sort where ecmpricebook_id='".$_REQUEST['record']."'"))==0)$zz="select id from ecmproductcategories where deleted='0' order by name asc";
|
||||
else $zz="select position,category_id as id from ecmpricebooks_ecmproducts_categories_sort where ecmpricebook_id='".$_REQUEST['record']."' order by position asc";
|
||||
$ww=$GLOBALS['db']->query($zz);
|
||||
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
|
||||
?>
|
||||
<?
|
||||
$z="select e.id,e.position,e.ecmproduct_id,p.product_category_name,p.name,p.code from ecmpricebooks_ecmproducts as e inner join ecmproducts as p on p.id=e.ecmproduct_id where e.ecmpricebook_id='".$_REQUEST['record']."' and e.deleted='0' and p.product_category_id='".$rr['id']."' order by e.position asc,p.product_category_name asc,p.code asc";
|
||||
$w=$GLOBALS['db']->query($z);
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
print '<li class="sortme" alt="'.$r['ecmproduct_id'].'"><table><tr><td width="100"><b>'.$r['code'].'</b></td><td width="150">'.$r['product_category_name'].'</td><td>'.$r['name'].'</td></tr></table></li>';
|
||||
$sort_order[] = $r['ecmproduct_id'];
|
||||
}
|
||||
?>
|
||||
|
||||
<?php echo '<br>';} ?>
|
||||
</ul>
|
||||
<input type="hidden" name="sort_order" id="sort_order" value="<?php echo implode($sort_order,'|'); ?>" />
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
16
modules/EcmPriceBooks2/saveProductsOrder.php
Executable file
16
modules/EcmPriceBooks2/saveProductsOrder.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
set_time_limit(9999999);
|
||||
$b=explode(",",str_replace(" ","",$_GET['boxes']));
|
||||
$i=1;
|
||||
foreach($b as $box){
|
||||
if(strlen($box)>=1 && $box!="" && $box!=" ")$boxy[]=$box;
|
||||
}
|
||||
for($i=1;$i<=count($boxy);$i++){
|
||||
$z="update ecmpricebooks_ecmproducts set position='".$i."' where deleted='0' and ecmproduct_id='".$boxy[$i-1]."' and ecmpricebook_id='".$_REQUEST['record']."'";
|
||||
if($GLOBALS['db']->query($z))$ok=1;
|
||||
else $error="Error";
|
||||
}
|
||||
if($error)print $error;
|
||||
else print "Saved";
|
||||
exit;
|
||||
?>
|
||||
5
modules/EcmPriceBooks2/selectImages.php
Executable file
5
modules/EcmPriceBooks2/selectImages.php
Executable file
@@ -0,0 +1,5 @@
|
||||
<?
|
||||
if(!$_SESSION['pricebook_images_pdf'] || $_SESSION['pricebook_images_pdf']=="false")$_SESSION['pricebook_images_pdf']="true";
|
||||
else $_SESSION['pricebook_images_pdf']="false";
|
||||
print "1";
|
||||
?>
|
||||
2
modules/EcmPriceBooks2/showEmail.php
Executable file
2
modules/EcmPriceBooks2/showEmail.php
Executable file
@@ -0,0 +1,2 @@
|
||||
<? session_start();$seid=$_SESSION['pricebook_id'];?>
|
||||
<iframe id=\'emailIFRAME\' style='border:none;width:100%;height:670px;' frameborder='no' src='index.php?module=EcmPriceBooks&action=Emails&to_pdf=1&bodyclass=tabForm&type=out&pricebook_id=<?print $seid;?>'>Yours browser not accept iframes!</iframe>
|
||||
1
modules/EcmPriceBooks2/showPDF.php
Executable file
1
modules/EcmPriceBooks2/showPDF.php
Executable file
@@ -0,0 +1 @@
|
||||
<iframe style='border:none;width:100%;height:500px;' frameborder='no' src='index.php?module=EcmPriceBooks&action=CreatePDF&to_pdf=1&disposition=I&images=<?print $_REQUEST['images'];?>'>Yours browser not accept iframes!</iframe>
|
||||
1
modules/EcmPriceBooks2/showXLS.php
Executable file
1
modules/EcmPriceBooks2/showXLS.php
Executable file
@@ -0,0 +1 @@
|
||||
<iframe style='border:none;width:100%;height:1200px;' frameborder='no' src='index.php?module=EcmPriceBooks&action=CreateXLS&to_pdf=1&disposition=D'>Yours browser not accept iframes!</iframe>
|
||||
5
modules/EcmPriceBooks2/showrecipientcode.php
Executable file
5
modules/EcmPriceBooks2/showrecipientcode.php
Executable file
@@ -0,0 +1,5 @@
|
||||
<?
|
||||
$w=$GLOBALS['db']->query("select recipient_code,ecmproduct_id,ecmpricebook_id from ecmpricebooks_ecmproducts where recipient_code!='' and recipient_code IS NOT NULL");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
print "update ecmpricebooks_ecmproducts set recipient_code='".$r['recipient_code']."' where ecmproduct_id='".$r['ecmproduct_id']."' and ecmpricebook_id='".$r['ecmpricebook_id']."';<br>";
|
||||
}
|
||||
82
modules/EcmPriceBooks2/subpanels/default.php
Executable file
82
modules/EcmPriceBooks2/subpanels/default.php
Executable file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$subpanel_layout = array(
|
||||
'top_buttons' => array(
|
||||
array('widget_class' => 'SubPanelTopCreateButton'),
|
||||
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'EcmPriceBooks'),
|
||||
),
|
||||
|
||||
'where' => '',
|
||||
|
||||
'list_fields' => array(
|
||||
'name'=>array(
|
||||
'vname' => 'LBL_LIST_NAME',
|
||||
'widget_class' => 'SubPanelDetailViewLink',
|
||||
'width' => '50%',
|
||||
),
|
||||
'assigned_user_name' => array (
|
||||
'name' => 'assigned_user_name',
|
||||
'vname' => 'LBL_LIST_ASSIGNED_TO_NAME',
|
||||
),
|
||||
'edit_button'=>array(
|
||||
'widget_class' => 'SubPanelEditButton',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'width' => '4%',
|
||||
),
|
||||
'remove_button'=>array(
|
||||
'widget_class' => 'SubPanelRemoveButton',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'width' => '5%',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
36
modules/EcmPriceBooks2/updatePrices.php
Executable file
36
modules/EcmPriceBooks2/updatePrices.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
$db = $GLOBALS['db'];
|
||||
|
||||
$res = $db->query("SELECT p.purchase_price as price, p.vat_value, pp.id, p.srp_price, p.srp_price_eur, pr.exchange_rate_id FROM ecmpricebooks_ecmproducts as pp INNER JOIN ecmproducts AS p ON p.id=pp.ecmproduct_id INNER JOIN ecmpricebooks as pr ON pp.ecmpricebook_id=pr.id WHERE pp.ecmpricebook_id='".$_REQUEST['record']."' and pp.deleted='0'");
|
||||
|
||||
//echo "SELECT p.purchase_price as price, p.vat_value, pp.id, p.srp_price, p.srp_price_eur, pp.exchange_rate_id FROM ecmpricebooks_ecmproducts as pp INNER JOIN ecmproducts AS p ON p.id=pp.ecmproduct_id WHERE pp.ecmpricebook_id='".$_REQUEST['record']."' and pp.deleted='0'";
|
||||
|
||||
|
||||
while ($row = $db->fetchByAssoc($res)) {
|
||||
if ($_REQUEST['type']=="1") {
|
||||
$price = $row['price'] * (1 + $_REQUEST['margin']/100);
|
||||
|
||||
if (intval($_REQUEST['discount'])>0)
|
||||
$price = $price - ($price * ($_REQUEST['discount']/100));
|
||||
|
||||
if (isset($_REQUEST['with_tax']) && $_REQUEST['with_tax']=='on')
|
||||
$price = $price * (1 + $row['vat_value']/100);
|
||||
}
|
||||
if ($_REQUEST['type']=="2") {
|
||||
if ($row['exchange_rate_id']=='-99')
|
||||
$price = $row['srp_price'];
|
||||
else $price = $row['srp_price_eur'];
|
||||
|
||||
if (!isset($_REQUEST['with_tax']))
|
||||
$price = round($price * 100 / (100 + $row['vat_value']),2);
|
||||
|
||||
if (intval($_REQUEST['discount'])>0)
|
||||
$price = $price - ($price * ($_REQUEST['discount']/100));
|
||||
|
||||
$db->query("update ecmpricebooks set currency_value='1' where id='".$_REQUEST['record']."'");
|
||||
//echo "update ecmpricebooks set currency_value='1' where id='".$_REQUEST['record']."'"; die();
|
||||
|
||||
}
|
||||
$db->query("UPDATE ecmpricebooks_ecmproducts SET price='".$price."' WHERE id='".$row['id']."'");
|
||||
}
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_REQUEST['record']."&tab=items");
|
||||
11
modules/EcmPriceBooks2/update_accounts_ecmproducts.php
Executable file
11
modules/EcmPriceBooks2/update_accounts_ecmproducts.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$w=$GLOBALS['db']->query("select id,account_id from ecmpricebooks where deleted='0'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$ww=$GLOBALS['db']->query("select ecmproduct_id from ecmpricebooks_ecmproducts where deleted='0' and ecmpricebook_id='".$r['id']."'");
|
||||
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
|
||||
if(mysql_num_rows($GLOBALS['db']->query("select id from accounts_ecmproducts where account_id='".$r['account_id']."' and ecmproduct_id='".$rr['ecmproduct_id']."' and deleted='0'"))==0){
|
||||
$GLOBALS['db']->query("insert into accounts_ecmproducts set id='".create_guid()."',account_id='".$r['account_id']."',ecmproduct_id='".$rr['ecmproduct_id']."',date_modified='".date("Y-m-d H:i:s")."',deleted='0'");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
6
modules/EcmPriceBooks2/updatepc.php
Executable file
6
modules/EcmPriceBooks2/updatepc.php
Executable file
@@ -0,0 +1,6 @@
|
||||
<?
|
||||
$w=$GLOBALS['db']->query("select productcategory,productcategoryen from productcategory");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$GLOBALS['db']->query("update ecmproductcategories set name_en='".$r['productcategoryen']."' where name like '".$r['productcategory']."'");
|
||||
}
|
||||
?>
|
||||
7
modules/EcmPriceBooks2/updaterecipientcode.php
Executable file
7
modules/EcmPriceBooks2/updaterecipientcode.php
Executable file
@@ -0,0 +1,7 @@
|
||||
<?
|
||||
$w=$GLOBALS['db']->query("select recipientcode,pricebookid,productid from pricebookproductrel");
|
||||
print mysql_error();
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set recipient_code='".$r['recipientcode']."' where ecmproduct_id='".$r['productid']."' and ecmpricebook_id='".$r['pricebookid']."'");
|
||||
}
|
||||
?>
|
||||
11
modules/EcmPriceBooks2/updateremarks.php
Executable file
11
modules/EcmPriceBooks2/updateremarks.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<textarea><?
|
||||
$w=$GLOBALS['db']->query("select * from ecmproduct_language");
|
||||
print mysql_error();
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
if($r['language']=="PL")print "update ecmpricebooks_ecmproducts set remarks_pl='".$r['remarks']."' where ecmproduct_id='".$r['ecmproduct_id']."'";
|
||||
if($r['language']=="EN")print "update ecmpricebooks_ecmproducts set remarks_en='".$r['remarks']."' where ecmproduct_id='".$r['ecmproduct_id']."'";
|
||||
if($r['language']=="DE")print "update ecmpricebooks_ecmproducts set remarks_de='".$r['remarks']."' where ecmproduct_id='".$r['ecmproduct_id']."'";
|
||||
print "<br>";
|
||||
}
|
||||
|
||||
?></textarea>
|
||||
386
modules/EcmPriceBooks2/vardefs.php
Executable file
386
modules/EcmPriceBooks2/vardefs.php
Executable file
@@ -0,0 +1,386 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
$dictionary['EcmPriceBook'] = array(
|
||||
'table' => 'ecmpricebooks',
|
||||
'audited' => true,
|
||||
'comment' => 'EcmPriceBooks',
|
||||
'duplicate_merge' => true,
|
||||
'unified_search' => true,
|
||||
'fields' => array (
|
||||
//STANDARD FIELDS SECTION
|
||||
'id' => array (
|
||||
'name' => 'id',
|
||||
'vname' => 'LBL_ID',
|
||||
'type' => 'id',
|
||||
'required' => true,
|
||||
'reportable' => false,
|
||||
'comment' => 'Unique identifier'
|
||||
),
|
||||
'name' => array (
|
||||
'name' => 'name',
|
||||
'vname' => 'LBL_NAME',
|
||||
'type' => 'name',
|
||||
'required' => true,
|
||||
'dbType' => 'varchar',
|
||||
'len' => 255,
|
||||
'audited' => true,
|
||||
'unified_search' => true,
|
||||
'comment' => 'The short description of the record contents',
|
||||
'massupdate' => true,
|
||||
'merge_filter' => 'selected',
|
||||
),
|
||||
'date_entered' => array (
|
||||
'name' => 'date_entered',
|
||||
'vname' => 'LBL_DATE_ENTERED',
|
||||
'type' => 'datetime',
|
||||
'required' => true,
|
||||
'comment' => 'Date record created'
|
||||
),
|
||||
'date_modified' => array (
|
||||
'name' => 'date_modified',
|
||||
'vname' => 'LBL_DATE_MODIFIED',
|
||||
'type' => 'datetime',
|
||||
'required' => true,
|
||||
'comment' => 'Date record last modified'
|
||||
),
|
||||
'modified_user_id' => array (
|
||||
'name' => 'modified_user_id',
|
||||
'rname' => 'user_name',
|
||||
'id_name' => 'modified_user_id',
|
||||
'vname' => 'LBL_MODIFIED',
|
||||
'type' => 'assigned_user_name',
|
||||
'table' => 'modified_user_id_users',
|
||||
'isnull' => 'false',
|
||||
'dbType' => 'varchar',
|
||||
'len' => 36,
|
||||
'required' => true,
|
||||
'reportable' => true,
|
||||
'comment' => 'User who last modified record'
|
||||
),
|
||||
'assigned_user_id' =>
|
||||
|
||||
array (
|
||||
|
||||
'name' => 'assigned_user_id',
|
||||
|
||||
'rname' => 'user_name',
|
||||
|
||||
'id_name' => 'assigned_user_id',
|
||||
|
||||
'vname' => 'LBL_ASSIGNED_TO_ID',
|
||||
|
||||
'group' => 'assigned_user_name',
|
||||
|
||||
'type' => 'relate',
|
||||
|
||||
'table' => 'users',
|
||||
|
||||
'reportable' => true,
|
||||
|
||||
'Importable' => false,
|
||||
|
||||
'isnull' => 'false',
|
||||
|
||||
'dbType' => 'id',
|
||||
|
||||
'audited' => true,
|
||||
|
||||
'comment' => 'User ID assigned to record',
|
||||
|
||||
'duplicate_merge' => 'disabled',
|
||||
|
||||
'massupdate' => false,
|
||||
|
||||
),
|
||||
|
||||
'assigned_user_name' =>
|
||||
|
||||
array (
|
||||
|
||||
'name' => 'assigned_user_name',
|
||||
|
||||
'vname' => 'LBL_ASSIGNED_TO',
|
||||
|
||||
'type' => 'relate',
|
||||
|
||||
'reportable' => false,
|
||||
|
||||
'source' => 'non-db',
|
||||
|
||||
'table' => 'users',
|
||||
|
||||
'id_name' => 'assigned_user_id',
|
||||
|
||||
'module' => 'Users',
|
||||
|
||||
'duplicate_merge' => 'disabled',
|
||||
|
||||
'massupdate' => false,
|
||||
|
||||
),
|
||||
'created_by' => array (
|
||||
'name' => 'created_by',
|
||||
'rname' => 'user_name',
|
||||
'id_name' => 'created_by',
|
||||
'vname' => 'LBL_CREATED',
|
||||
'type' => 'assigned_user_name',
|
||||
'table' => 'created_by_users',
|
||||
'isnull' => 'false',
|
||||
'dbType' => 'varchar',
|
||||
'len' => 36,
|
||||
'comment' => 'User that created the record'
|
||||
),
|
||||
'created_by_link' => array (
|
||||
'name' => 'created_by_link',
|
||||
'type' => 'link',
|
||||
'relationship' => 'ecmpricebooks_created_by',
|
||||
'vname' => 'LBL_CREATED_BY_USER',
|
||||
'link_type' => 'one',
|
||||
'module' => 'Users',
|
||||
'bean_name' => 'User',
|
||||
'source' => 'non-db',
|
||||
),
|
||||
'modified_user_link' => array (
|
||||
'name' => 'modified_user_link',
|
||||
'type' => 'link',
|
||||
'relationship' => 'ecmpricebooks_modified_user',
|
||||
'vname' => 'LBL_MODIFIED_BY_USER',
|
||||
'link_type' => 'one',
|
||||
'module' => 'Users',
|
||||
'bean_name' => 'User',
|
||||
'source' => 'non-db',
|
||||
),
|
||||
'assigned_user_link' => array (
|
||||
'name' => 'assigned_user_link',
|
||||
'type' => 'link',
|
||||
'relationship' => 'ecmpricebooks_assigned_user',
|
||||
'vname' => 'LBL_ASSIGNED_TO_USER',
|
||||
'link_type' => 'one',
|
||||
'module' => 'Users',
|
||||
'bean_name' => 'User',
|
||||
'source' => 'non-db',
|
||||
'duplicate_merge' => 'enabled',
|
||||
'rname' => 'user_name',
|
||||
'id_name' => 'assigned_user_id',
|
||||
'table' => 'users',
|
||||
),
|
||||
'deleted' => array (
|
||||
'name' => 'deleted',
|
||||
'vname' => 'LBL_CREATED_BY',
|
||||
'type' => 'bool',
|
||||
'required' => true,
|
||||
'reportable' => false,
|
||||
'comment' => 'Record deletion indicator'
|
||||
),
|
||||
|
||||
//NEW FIELDS SECTION
|
||||
'active' => array(
|
||||
'type' => 'bool',
|
||||
'name' => 'active',
|
||||
'options' => 'ecmpricebooks_active_dom',
|
||||
'vname' => 'LBL_ACTIVE',
|
||||
'comment' => 'Product active',
|
||||
'default' => '1',
|
||||
),
|
||||
|
||||
'description' => array(
|
||||
'type' => 'text',
|
||||
'name' => 'description',
|
||||
'vname' => 'LBL_DESCRIPTION',
|
||||
'comment' => 'Description',
|
||||
'unified_search' => true,
|
||||
),
|
||||
|
||||
|
||||
'exchange_rate_id' =>
|
||||
array (
|
||||
'name' => 'exchange_rate_id',
|
||||
'type' => 'id',
|
||||
'group'=>'exchange_rate_id',
|
||||
'vname' => 'LBL_EXCHANGE_RATE_NAME',
|
||||
'function'=>array('name'=>'getCurrencyDropDown', 'returns'=>'html'),
|
||||
'reportable'=>false,
|
||||
'comment' => 'Currency used for display purposes'
|
||||
),
|
||||
'exchange_rate_name' =>
|
||||
array (
|
||||
'name' => 'exchange_rate_name',
|
||||
'vname' => 'LBL_EXCHANGE_RATE_NAME',
|
||||
'duplicate_merge' => 'disabled',
|
||||
'massupdate' => false,
|
||||
),
|
||||
|
||||
'account_id' =>
|
||||
array (
|
||||
'name' => 'account_id',
|
||||
'rname' => 'name',
|
||||
'id_name' => 'account_id',
|
||||
'vname' => 'LBL_ACCOUNT_ID',
|
||||
'group' => 'product_category_name',
|
||||
'type' => 'relate',
|
||||
'table' => 'accounts',
|
||||
'reportable' => true,
|
||||
'Importable' => false,
|
||||
'isnull' => 'false',
|
||||
'dbType' => 'id',
|
||||
'audited' => true,
|
||||
'duplicate_merge' => 'disabled',
|
||||
'massupdate' => false,
|
||||
),
|
||||
'account_name' =>
|
||||
array (
|
||||
'name' => 'account_name',
|
||||
'vname' => 'LBL_ACCOUNT_NAME',
|
||||
'type' => 'relate',
|
||||
'reportable' => false,
|
||||
//'source' => 'non-db',
|
||||
'table' => 'accounts',
|
||||
'id_name' => 'account_id',
|
||||
'module' => 'Accounts',
|
||||
'duplicate_merge' => 'disabled',
|
||||
'massupdate' => false,
|
||||
),
|
||||
|
||||
'lead_id' =>
|
||||
array (
|
||||
'name' => 'lead_id',
|
||||
'rname' => 'name',
|
||||
'id_name' => 'lead_id',
|
||||
'vname' => 'LBL_LEAD_ID',
|
||||
'group' => 'lead_name',
|
||||
'type' => 'relate',
|
||||
'table' => 'leads',
|
||||
'reportable' => true,
|
||||
'Importable' => false,
|
||||
'isnull' => 'false',
|
||||
'dbType' => 'id',
|
||||
'audited' => true,
|
||||
'duplicate_merge' => 'disabled',
|
||||
'massupdate' => false,
|
||||
),
|
||||
'lead_name' =>
|
||||
array (
|
||||
'name' => 'lead_name',
|
||||
'vname' => 'LBL_LEAD_NAME',
|
||||
'type' => 'relate',
|
||||
'reportable' => false,
|
||||
//'source' => 'non-db',
|
||||
'table' => 'leads',
|
||||
'id_name' => 'lead_id',
|
||||
'module' => 'Leads',
|
||||
'duplicate_merge' => 'disabled',
|
||||
'massupdate' => false,
|
||||
),
|
||||
|
||||
'price' => array (
|
||||
'name' => 'price',
|
||||
'type' => 'int',
|
||||
'len' => '1',
|
||||
'reportable'=>false,
|
||||
),
|
||||
'currency_value' => array (
|
||||
'name' => 'currency_value',
|
||||
'type' => 'decimal',
|
||||
'len' => '5,2',
|
||||
'vname'=>'LBL_CURRENCY_VALUE',
|
||||
'reportable'=>false,
|
||||
),
|
||||
'ecmlanguage' =>
|
||||
array(
|
||||
'name' => 'ecmlanguage',
|
||||
'vname' => 'LBL_ECMLANGUAGE',
|
||||
'type' => 'enum',
|
||||
'options' => 'ecmlanguages_dom',
|
||||
'required' => true,
|
||||
'len' => 35,
|
||||
'massupdate' => false,
|
||||
),
|
||||
/*'archived' =>
|
||||
array(
|
||||
'name'=>'archived',
|
||||
'vname'=>'LBL_ARCHIVED',
|
||||
'type'=>'bool',
|
||||
'len'=>1,
|
||||
),*/
|
||||
|
||||
|
||||
//FOR SUBPANELS
|
||||
|
||||
|
||||
),
|
||||
|
||||
//INDICES SECTION
|
||||
'indices' => array (
|
||||
array('name' =>'ecmpricebooksspk', 'type' =>'primary', 'fields'=>array('id')),
|
||||
array('name' =>'idx_ecmpricebooks_name', 'type' =>'index', 'fields'=>array('name'))
|
||||
)
|
||||
|
||||
//RELATIONSHIPS SECTION
|
||||
, 'relationships' => array (
|
||||
'ecmpricebooks_assigned_user' => array(
|
||||
'lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id',
|
||||
'rhs_module'=> 'EcmPriceBooks', 'rhs_table'=> 'ecmpricebooks', 'rhs_key' => 'assigned_user_id',
|
||||
'relationship_type'=>'one-to-many')
|
||||
|
||||
,'ecmpricebooks_modified_user' => array(
|
||||
'lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id',
|
||||
'rhs_module'=> 'EcmPriceBooks', 'rhs_table'=> 'ecmpricebooks', 'rhs_key' => 'modified_user_id',
|
||||
'relationship_type'=>'one-to-many')
|
||||
|
||||
,'ecmpricebooks_created_by' => array(
|
||||
'lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id',
|
||||
'rhs_module'=> 'EcmPriceBooks', 'rhs_table'=> 'ecmpricebooks', 'rhs_key' => 'created_by',
|
||||
'relationship_type'=>'one-to-many')
|
||||
|
||||
),
|
||||
//THIS FLAG ENABLES OPTIMISTIC LOCKING FOR SAVES FROM EDITVIEW
|
||||
'optimistic_locking'=>true,
|
||||
);
|
||||
?>
|
||||
253
modules/EcmPriceBooks2/views/view.list.php
Executable file
253
modules/EcmPriceBooks2/views/view.list.php
Executable file
@@ -0,0 +1,253 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: This file is used to override the default Meta-data EditView behavior
|
||||
* to provide customization specific to the Calls module.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/MVC/View/views/view.list.php');
|
||||
|
||||
class EcmPriceBooksViewList extends ViewList{
|
||||
|
||||
function EcmPriceBooksViewList(){
|
||||
|
||||
parent::ViewList();
|
||||
}
|
||||
|
||||
function display(){
|
||||
if(!$this->bean->ACLAccess('list')){
|
||||
ACLController::displayNoAccess();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->module=$module = "EcmPriceBooks";
|
||||
$metadataFile = null;
|
||||
$foundViewDefs = false;
|
||||
if(file_exists('custom/modules/' . $module. '/metadata/listviewdefs.php')){
|
||||
$metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
|
||||
$foundViewDefs = true;
|
||||
}else{
|
||||
if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
|
||||
require_once('custom/modules/'.$module.'/metadata/metafiles.php');
|
||||
if(!empty($metafiles[$module]['listviewdefs'])){
|
||||
$metadataFile = $metafiles[$module]['listviewdefs'];
|
||||
$foundViewDefs = true;
|
||||
}
|
||||
}elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
|
||||
require_once('modules/'.$module.'/metadata/metafiles.php');
|
||||
if(!empty($metafiles[$module]['listviewdefs'])){
|
||||
$metadataFile = $metafiles[$module]['listviewdefs'];
|
||||
$foundViewDefs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
|
||||
$metadataFile = 'modules/'.$module.'/metadata/listviewdefs.php';
|
||||
}
|
||||
require_once($metadataFile);
|
||||
|
||||
if(!empty($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select']!='_none') {
|
||||
if(empty($_REQUEST['button']) && (empty($_REQUEST['clear_query']) || $_REQUEST['clear_query']!='true')) {
|
||||
$this->saved_search = loadBean('SavedSearch');
|
||||
$this->saved_search->retrieveSavedSearch($_REQUEST['saved_search_select']);
|
||||
$this->saved_search->populateRequest();
|
||||
}
|
||||
elseif(!empty($_REQUEST['button'])) { // click the search button, after retrieving from saved_search
|
||||
$_SESSION['LastSavedView'][$_REQUEST['module']] = '';
|
||||
unset($_REQUEST['saved_search_select']);
|
||||
unset($_REQUEST['saved_search_select_name']);
|
||||
}
|
||||
}
|
||||
|
||||
$storeQuery = new StoreQuery();
|
||||
if(!isset($_REQUEST['query'])){
|
||||
$storeQuery->loadQuery($this->module);
|
||||
$storeQuery->populateRequest();
|
||||
}else{
|
||||
$storeQuery->saveFromRequest($this->module);
|
||||
}
|
||||
|
||||
$seed = $this->bean;
|
||||
$lv = new ListViewSmarty();
|
||||
$displayColumns = array();
|
||||
if(!empty($_REQUEST['displayColumns'])) {
|
||||
foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
|
||||
if(!empty($listViewDefs[$module][$col]))
|
||||
$displayColumns[$col] = $listViewDefs[$module][$col];
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach($listViewDefs[$module] as $col => $params) {
|
||||
if(!empty($params['default']) && $params['default'])
|
||||
$displayColumns[$col] = $params;
|
||||
}
|
||||
}
|
||||
$params = array('massupdate' => true, 'export'=>false);
|
||||
|
||||
$lv->quickViewLinks = false;
|
||||
$lv->export = false;
|
||||
$lv->mergeduplicates = false;
|
||||
$lv->createEcmInvoiceOut = true;
|
||||
|
||||
if(!empty($_REQUEST['orderBy'])) {
|
||||
$params['orderBy'] = $_REQUEST['orderBy'];
|
||||
$params['overrideOrder'] = true;
|
||||
if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
|
||||
}
|
||||
|
||||
$lv->displayColumns = $displayColumns;
|
||||
|
||||
$this->seed = $seed;
|
||||
$this->module = $module;
|
||||
|
||||
$searchForm = null;
|
||||
|
||||
//search
|
||||
$view = 'basic_search';
|
||||
if(!empty($_REQUEST['search_form_view']))
|
||||
$view = $_REQUEST['search_form_view'];
|
||||
$headers = true;
|
||||
if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only'])
|
||||
$headers = false;
|
||||
elseif(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
|
||||
if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
|
||||
$view = 'advanced_search';
|
||||
}else {
|
||||
$view = 'basic_search';
|
||||
}
|
||||
}
|
||||
|
||||
$use_old_search = true;
|
||||
if(file_exists('modules/'.$this->module.'/SearchForm.html')){
|
||||
require_once('include/SearchForm/SearchForm.php');
|
||||
$searchForm = new SearchForm($this->module, $this->seed);
|
||||
}else{
|
||||
$use_old_search = false;
|
||||
require_once('include/SearchForm/SearchForm2.php');
|
||||
|
||||
if(!empty($metafiles[$this->module]['searchdefs']))
|
||||
require_once($metafiles[$this->module]['searchdefs']);
|
||||
elseif(file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
|
||||
require_once('modules/'.$this->module.'/metadata/searchdefs.php');
|
||||
|
||||
if (file_exists('custom/modules/'.$this->module.'/metadata/searchdefs.php'))
|
||||
{
|
||||
require_once('custom/modules/'.$this->module.'/metadata/searchdefs.php');
|
||||
}
|
||||
elseif (!empty($metafiles[$this->module]['searchdefs']))
|
||||
{
|
||||
require_once($metafiles[$this->module]['searchdefs']);
|
||||
}
|
||||
elseif (file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
|
||||
{
|
||||
require_once('modules/'.$this->module.'/metadata/searchdefs.php');
|
||||
}
|
||||
|
||||
if(!empty($metafiles[$this->module]['searchfields']))
|
||||
require_once($metafiles[$this->module]['searchfields']);
|
||||
elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php'))
|
||||
require_once('modules/'.$this->module.'/metadata/SearchFields.php');
|
||||
|
||||
$searchForm = new SearchForm($this->seed, $this->module, $this->action);
|
||||
$searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl', $view, $listViewDefs);
|
||||
|
||||
$searchForm->lv = $lv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isset($this->options['show_title']) && $this->options['show_title'] && (!isset($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] != "true")) {
|
||||
$moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
|
||||
|
||||
echo "\n<p>\n";
|
||||
echo get_module_title($moduleName, $GLOBALS['mod_strings']['LBL_MODULE_TITLE'], true);
|
||||
echo "\n</p>\n";
|
||||
|
||||
}
|
||||
|
||||
$where = '';
|
||||
if(isset($_REQUEST['query']))
|
||||
{
|
||||
// we have a query
|
||||
if(!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) { // from EditView cancel
|
||||
$searchForm->populateFromArray($storeQuery->query);
|
||||
}
|
||||
else {
|
||||
$searchForm->populateFromRequest();
|
||||
}
|
||||
$where_clauses = $searchForm->generateSearchWhere(true, $this->seed->module_dir);
|
||||
if (count($where_clauses) > 0 )$where = '('. implode(' ) AND ( ', $where_clauses) . ')';
|
||||
$GLOBALS['log']->info("List View Where Clause: $where");
|
||||
}
|
||||
if($use_old_search){
|
||||
switch($view) {
|
||||
case 'basic_search':
|
||||
$searchForm->setup();
|
||||
$searchForm->displayBasic($headers);
|
||||
break;
|
||||
case 'advanced_search':
|
||||
$searchForm->setup();
|
||||
$searchForm->displayAdvanced($headers);
|
||||
break;
|
||||
case 'saved_views':
|
||||
echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
|
||||
break;
|
||||
}
|
||||
|
||||
}else{
|
||||
echo $searchForm->display($headers);
|
||||
}
|
||||
if(!$headers)
|
||||
return;
|
||||
|
||||
if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false){
|
||||
// $this->processQuickSearch();
|
||||
$lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
|
||||
$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
|
||||
echo get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'] . $savedSearchName, '', false);
|
||||
echo $lv->display();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user