This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

View 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 ecmprices_ecmproducts where ecmprice_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 ecmprices_ecmproducts(id,ecmprice_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 ecmprices_ecmproducts set price='".$price."' where ecmprice_id='".$_REQUEST['pricebook_id']."' and ecmproduct_id='".$_REQUEST['check'][$i]."'";
$GLOBALS['db']->query($z);
}
}
//print mysql_error();
header("Location: index.php?module=EcmPrices&action=DetailView&record=".$_REQUEST['pricebook_id']."&tab=items");
?>

View File

@@ -0,0 +1,375 @@
<?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/EcmPrices/ListHelper.php");
$_SESSION['pricebook_images']=$_REQUEST['images'];
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id,description,ecmlanguage,currency_value from ecmprices where id='".$_SESSION['pricebook_id']."'"));
$name=$r['name'];
$description=$r['description'];
$exchange_rate_id=$r['exchange_rate_id'];
$lang=$_REQUEST['langs'];
//echo $lang;
//die($lang);
$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 ecmprices_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[]="ecmprices_ecmproducts.id!='".$key."'";
$orand=' and ';
}
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
$where_clauses[]="ecmprices_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="ecmprices_ecmproducts.id='9999999999999999' and ";
}
else $where="ecmprices_ecmproducts.id='9999999999999999' and ";
//print $where;
$z="select
ecmprices_ecmproducts.price as price,
ecmprices_ecmproducts.recipient_code as recipient_code,
ecmprices_ecmproducts.id as idp,
ecmprices_ecmproducts.remarks_pl as remarks_pl,
ecmprices_ecmproducts.remarks_en as remarks_en,
ecmprices_ecmproducts.remarks_de as remarks_de,
ecmproducts.*,
if(ecmprices_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmprices_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 ecmprices_ecmproducts
left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id
left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id
left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id
left join ecmproducts on ecmproducts.id=ecmprices_ecmproducts.ecmproduct_id
where ".$where." ecmprices_ecmproducts.ecmprice_id='".$_SESSION['pricebook_id']."' and ecmprices_ecmproducts.deleted='0'";
//$z.="order by ecmproducts.product_category_name asc,ecmprices_ecmproducts.price asc";
if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order'];
else
$z.=" order by ecmprices_ecmproducts.position";
$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/EcmPrices/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/EcmPrices/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">&nbsp;</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/EcmPrices/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");
}
?>

View File

@@ -0,0 +1,73 @@
<?
require_once("modules/EcmPrices/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 ecmprices 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 ecmprices_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[]="ecmprices_ecmproducts.id!='".$key."'";
$orand=' and ';
}
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
$where_clauses[]="ecmprices_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="ecmprices_ecmproducts.id='9999999999999999' and ";
}
else $where="ecmprices_ecmproducts.id='9999999999999999' and ";
$z="select ecmprices_ecmproducts.price as price,ecmprices_ecmproducts.recipient_code as recipient_code,ecmprices_ecmproducts.id as idp,ecmproducts.*,
if(ecmprices_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmprices_ecmproducts.price)),0) as margin_rate from ecmprices_ecmproducts left join ecmproducts on ecmproducts.id=ecmprices_ecmproducts.ecmproduct_id where ".$where."ecmprices_ecmproducts.ecmprice_id='".$_SESSION['pricebook_id']."' and ecmprices_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++;
}
?>

View File

@@ -0,0 +1,128 @@
<?
//require_once('include/write_excell/Worksheet.php');
//require_once('include/write_excell/Workbook.php');
require_once("modules/EcmPrices/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 ecmprices 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 ecmprices_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[]="ecmprices_ecmproducts.id!='".$key."'";
$orand=' and ';
}
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
$where_clauses[]="ecmprices_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="ecmprices_ecmproducts.id='9999999999999999' and ";
}
else $where="ecmprices_ecmproducts.id='9999999999999999' and ";
//print $where;
$z="select
ecmprices_ecmproducts.price as price,
ecmprices_ecmproducts.recipient_code as recipient_code,
ecmprices_ecmproducts.id as idp,
ecmprices_ecmproducts.remarks_pl as remarks_pl,
ecmprices_ecmproducts.remarks_en as remarks_en,
ecmprices_ecmproducts.remarks_de as remarks_de,
ecmproducts.*,
if(ecmprices_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmprices_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 ecmprices_ecmproducts
left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id
left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id
left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id
left join ecmproducts on ecmproducts.id=ecmprices_ecmproducts.ecmproduct_id
where ".$where." ecmprices_ecmproducts.ecmprice_id='".$_SESSION['pricebook_id']."' and ecmprices_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();
?>

View File

@@ -0,0 +1,240 @@
<?php
set_time_limit(99999999);
ini_set('display_errors',1);
require_once("modules/EcmPrices/ListHelper.php");
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id,ecmlanguage,currency_value from ecmprices where id='".$_COOKIE['pricebook_id']."'"));
$name=$r['name'];
$exchange_rate_id=$r['exchange_rate_id'];
$lang=$_REQUEST['langs2'];
$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 ecmprices_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[]="ecmprices_ecmproducts.id!='".$key."'";
$orand=' and ';
}
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
$where_clauses[]="ecmprices_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="ecmprices_ecmproducts.id='9999999999999999' and ";
}
else $where="ecmprices_ecmproducts.id='9999999999999999' and ";
//print $where;
$z="select
ecmprices_ecmproducts.price as price,
ecmprices_ecmproducts.recipient_code as recipient_code,
ecmprices_ecmproducts.id as idp,
ecmprices_ecmproducts.remarks_pl as remarks_pl,
ecmprices_ecmproducts.remarks_en as remarks_en,
ecmprices_ecmproducts.remarks_de as remarks_de,
ecmproducts.*,
if(ecmprices_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmprices_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 ecmprices_ecmproducts
left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id
left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id
left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id
left join ecmproducts on ecmproducts.id=ecmprices_ecmproducts.ecmproduct_id
where ".$where." ecmprices_ecmproducts.ecmprice_id='".$_SESSION['pricebook_id']."' and ecmprices_ecmproducts.deleted='0'";
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);
}
//$z.=" order by ".$_REQUEST['order_by'];
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);
?>

View File

@@ -0,0 +1,72 @@
<?
require_once("modules/EcmPrices/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 ecmprices 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 ecmprices_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[]="ecmprices_ecmproducts.id!='".$key."'";
$orand=' and ';
}
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
$where_clauses[]="ecmprices_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="ecmprices_ecmproducts.id='9999999999999999' and ";
}
else $where="ecmprices_ecmproducts.id='9999999999999999' and ";
$z="select ecmprices_ecmproducts.price as price,ecmprices_ecmproducts.recipient_code as recipient_code,ecmprices_ecmproducts.id as idp,ecmproducts.*,
if(ecmprices_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmprices_ecmproducts.price)),0) as margin_rate from ecmprices_ecmproducts left join ecmproducts on ecmproducts.id=ecmprices_ecmproducts.ecmproduct_id where ".$where."ecmprices_ecmproducts.ecmprice_id='".$_COOKIE['pricebook_id']."' and ecmprices_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;
?>

View File

@@ -0,0 +1,73 @@
<?
require_once("modules/EcmPrices/ListHelper.php");
require ("modules/EcmPrices/excel.php");
$workbook = "test.xls";
$pathin = "/var/www/html/e5crm/vserver/e5crm.more7.com/www/e5test/modules/EcmPrices/";
$sheet = "test";
$pathout = "/";
$E = new Excel;
$E->XL($workbook,$pathin,$sheet);
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmprices 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 ecmprices_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[]="ecmprices_ecmproducts.id!='".$key."'";
$orand=' and ';
}
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
$where_clauses[]="ecmprices_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="ecmprices_ecmproducts.id='9999999999999999' and ";
}
else $where="ecmprices_ecmproducts.id='9999999999999999' and ";
$result = $GLOBALS['db']->query("select ecmprices_ecmproducts.price as price,ecmprices_ecmproducts.id as idp,ecmproducts.* from ecmprices_ecmproducts left join ecmproducts on ecmproducts.id=ecmprices_ecmproducts.ecmproduct_id where ".$where."ecmprices_ecmproducts.ecmprice_id='".$_COOKIE['pricebook_id']."' and ecmprices_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);
?>

View File

@@ -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['MyEcmPricesDashlet']['searchFields'] = array(
'date_entered' => array('default' => ''),
'date_modified' => array('default' => ''),
'assigned_user_id' => array('type' => 'assigned_user_name',
'default' => $current_user->name)
);
$dashletData['MyEcmPricesDashlet']['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'),
);
?>

View File

@@ -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['MyEcmPricesDashlet'] = array(
'title' => translate('LBL_LIST_MY_ECMPRICES', 'EcmPrices'),
'icon' => 'modules/EcmPrices/images/EcmPrices.gif',
'description' => 'A customizable view into EcmPrices',
'category' => 'Module Views',
'hidden' => true);
?>

View File

@@ -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/EcmPrices/EcmPrice.php');
require_once('modules/EcmPrices/Dashlets/MyEcmPricesDashlets/MyEcmPricesDashlet.data.php');
class MyEcmPricesDashlet extends DashletGeneric {
function MyEcmPricesDashlet($id, $def = null) {
global $current_user, $app_strings, $dashletData;
parent::DashletGeneric($id, $def);
$this->searchFields = $dashletData['MyEcmPricesDashlet']['searchFields'];
$this->columns = $dashletData['MyEcmPricesDashlet']['columns'];
if(empty($def['title']))
$this->title = translate('LBL_LIST_MY_ECMPRICES', 'EcmPrices');
$this->seedBean = new EcmPrice();
}
function displayOptions() {
$this->processDisplayOptions();
$this->configureSS->assign('searchFields', $this->currentSearchFields);
return $this->configureSS->fetch($this->configureTpl);
}
}
?>

View 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/EcmPrices/EcmPrice.php');
$focus = new EcmPrice();
// 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']);
?>

View File

@@ -0,0 +1,7 @@
<?
$sugarEntry=true;
global $db;
$db->query("delete from ecmprices_customview where id='".$_REQUEST['record']."'");
header("Location: index.php?module=EcmPrices&action=DetailView&record=".$_COOKIE['pricebook_id']);
?>

View 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 ecmprices_ecmproducts set deleted='1' where ecmprice_id='".$_REQUEST['pricebook_id']."' and ecmproduct_id='".$_REQUEST['record']."'");
$_REQUEST['customview_id']=$_COOKIE['customview_id'];
include("modules/EcmPrices/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 ecmprices_ecmproducts set date_modified='".date("Y-m-d H:i:s")."',modified_user_id='".$_SESSION['authenticated_user_id']."',deleted='1' where id='".$key."' and ecmprice_id='".$_REQUEST['return_id']."'");
$input[]=$key;
}
}
}
//print mysql_error();
if(count($input)>0){
echo '<form action="index.php?module=EcmPrices&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 ecmprices_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>';
}
?>

View 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 ecmprices_ecmproducts where id='".$key."'");
}
}
header("Location: index.php?module=EcmPrices&action=DetailView&record=".$_REQUEST['return_id']);
?>

View File

@@ -0,0 +1,154 @@
<!--
/*****************************************************************************
* 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.
********************************************************************************/
-->
<!-- BEGIN: main -->
<script language="javascript" src="modules/EcmProducts/mintajax.js"></script>
<script language="javascript" src="modules/EcmProducts/helper.js"></script>
<table cellpadding="0" cellspacing="0" border="0">
<form action="index.php" method="post" name="DetailView" id="form">
<input type="hidden" name="module" value="EcmPrices">
<input type="hidden" name="record" value="{ID}">
<input type="hidden" name="isDuplicate" value=false>
<input type="hidden" name="action">
<input type="hidden" name="return_module">
<input type="hidden" name="return_action">
<input type="hidden" name="return_id" >
<tr>
<td style="padding-bottom: 2px;">
<input {NAME_style} title="{APP.LBL_EDIT_BUTTON_TITLE}"
accessKey="{APP.LBL_EDIT_BUTTON_KEY}"
class="button"
onclick="this.form.return_module.value='EcmPrices'; this.form.return_action.value='DetailView'; this.form.return_id.value='{ID}'; this.form.action.value='EditView'"
type="submit"
name="Edit"
value=" {APP.LBL_EDIT_BUTTON_LABEL} "> </td><td>
<input {NAME_style} title="{APP.LBL_DELETE_BUTTON_TITLE}"
accessKey="{APP.LBL_DELETE_BUTTON_KEY}"
class="button"
onclick="this.form.return_module.value='EcmPrices'; this.form.return_action.value='ListView'; this.form.action.value='Delete'; return confirm('{APP.NTC_DELETE_CONFIRMATION}')"
type="submit"
name="Delete"
value=" {APP.LBL_DELETE_BUTTON_LABEL} "></td><td>
<td align='right'>{ADMIN_EDIT}</td>
</tr>
</table>
</form>
<script language="javascript" src="include/ECM/EcmPreviewPDF/EcmPreviewPDF.js"></script>
<script>
function showBlock(id)
{
var tabs=new Array();
tabs[0]="details";
tabs[1]="items";
document.getElementById('images_block').style.display='none';
for(var i=0;i<=1;i++)
{
document.getElementById(tabs[i]+'_menu').className="";
document.getElementById(tabs[i]+'_link').className="";
document.getElementById(tabs[i]+'_block').style.display="none";
}
if(id=="previewpdf")document.getElementById('images_block').style.display='block';
document.getElementById(id+'_menu').className="active";
document.getElementById(id+'_link').className="current";
document.getElementById(id+'_block').style.display="block";
}
</script>
<ul class="subpanelTablist" style="margin-top:10px;" id="groupTabs">
<li class="active" id="details_menu"><a id="details_link" class="current" href="javascript:showBlock('details');">{MOD.LBL_DETAILS}</a></li>
<!--<li class="" id="previewxls_menu"><a id="previewxls_link" class="" href="javascript:showBlock('previewxls');mintajaxget('index.php?to_pdf=1&module=EcmPrices&action=showXLS','previewxls_block');">{MOD.LBL_PREVIEWXLS}</a></li>-->
</ul>
<br />
<div id="details_block" style="display:block;">
<table width="100%" border="0" cellspacing="{GRIDLINE}" cellpadding="0">
{PAGINATION1}
<th class="dataLabel" align="left" colspan="8">
<h4>{MOD.LBL_PRICE_DETAIL_NAME}</h4></th>
<tr>
<td width="15%" class="tabDetailViewDL"><span sugar='slot1'>{MOD.LBL_NAME}</span sugar='slot'></td>
<td width="35%" class="tabDetailViewDF"><span sugar='slot1b'>{NAME}&nbsp;</span sugar='slot'></td>
<td width="15%" valign="top" class="tabDetailViewDL"><span sugar='slot2'>{APP.LBL_ASSIGNED_TO}</span sugar='slot'></td>
<td width="35%" valign="top" class="tabDetailViewDF"><span sugar='slot2b'>{ASSIGNED_TO}</span sugar='slot'></td>
</tr>
<tr>
<td valign="top" class="tabDetailViewDL"><span sugar='slot4'>{MOD.LBL_DESCRIPTION}</span sugar='slot'></td>
<td valign="top" class="tabDetailViewDF"><span sugar='slot4b'>{DESCRIPTION}&nbsp;</span sugar='slot'></td>
<td valign="top" class="tabDetailViewDL"><span sugar='slot5'>{MOD.LBL_EXCHANGE_RATE_NAME}</span sugar='slot'></td>
<td valign="top" class="tabDetailViewDF"><span sugar='slot5b'>{CURRENCY}</span sugar='slot'></td>
</tr>
<tr>
<td valign="top" class="tabDetailViewDL">&nbsp;</td>
<td valign="top" class="tabDetailViewDF">&nbsp;</td>
<td valign="top" class="tabDetailViewDL">&nbsp;</td>
<td valign="top" class="tabDetailViewDF">&nbsp;</td>
</tr>
</table>
</div>
<div id="images_block" style="display:none;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td class="dataLabel" align="left" width="15%">
<h4>{MOD.LBL_PREVIEWPDF}</h4>
</td><td width="85%"></td></tr></table></div>
<div id="previewpdf_block" style="display:none;"></div>
<div id="previewxls_block" style="display:none;"></div>
{LOAD_TAB}
<!-- END: main -->
<!-- BEGIN: subpanel -->
<span sugar='slot23'>{SUBPANEL}</span sugar='slot'>
<!-- END: subpanel -->

View File

@@ -0,0 +1,301 @@
<?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/EcmPrices/EcmPrice.php');
require_once ('modules/EcmPrices/Forms.php');
require_once ('include/DetailView/DetailView.php');
global $mod_strings;
global $app_strings;
global $db;
$focus = new EcmPrice ();
$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 ( "ECMPRICES", $focus, $offset );
if ($result == null) {
sugar_die ( $app_strings ['ERROR_NO_RECORD'] );
}
$focus = $result;
} else {
header ( "Location: index.php?module={EcmPrices}&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 ecmprices_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 ( "EcmPrices detail view" );
$focus->format_all_fields ();
$xtpl = new XTemplate ( 'modules/EcmPrices/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 ( "ecmprices", "EcmPrices", $_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 .= $mod_strings ['LBL_IMAGE_S'] . ': <select name="new_image" id="new_image"><option value="1">Yes</option><option value="0" selected>No</option></select><br /><br />';
$desc .= $mod_strings ['LBL_LIST_PRICE_NAME_A'] . ': <select name="new_show_price" id="new_show_price"><option value="1">Yes</option><option value="0" selected>No</option></select><br /><br />';
$desc .= $mod_strings ['LBL_LIST_PRICE_NAME'] . ': <select name="new_price" id="new_price"><option value="pricebook_price">Pricebook price</option><option value="srp_price">SRP Price</option></select><br /><br />';
$desc .= $mod_strings ['LBL_LANGS'] . ': <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="' . $mod_strings ['LBL_PRODUCT_CARD'] . '" 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=EcmPrices&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=EcmPrices&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 ecmprices_ecmproducts where ecmprice_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 ecmprices_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 ecmprices_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=EcmPrices&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>&nbsp;<a style="cursor:pointer;" onclick="location.href=\'index.php?module=EcmPrices&action=EditCustomView&record=\'+document.getElementById(\'customview\').value;">' . $mod_strings ['LBL_CV_EDIT'] . '</a>&nbsp;|&nbsp;<a style="cursor:pointer;" onclick="if(confirm(\'' . $mod_strings ['LBL_CV_QUESTION'] . '\'))location.href=\'index.php?module=EcmPrices&action=DeleteCustomView&record=\'+document.getElementById(\'customview\').value;">' . $mod_strings ['LBL_CV_DELETE'] . '</a>&nbsp;|&nbsp;<a style="cursor:pointer;" onclick="location.href=\'index.php?module=EcmPrices&action=EditCustomView\';">' . $mod_strings ['LBL_CV_CREATE'] . '</a><script>mintajaxget(\'index.php?to_pdf=1&module=EcmPrices&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 );
$desc='';
$desc.='<input title="'.$mod_strings ['LBL_SHOW_PDF'] .'" class="button" onclick="if(document.getElementById(\'div_desc\').style.display==\'none\')document.getElementById(\'div_desc\').style.display=\'block\';else document.getElementById(\'div_desc\').style.display=\'none\';" type="button" name="productcard" id="productcard" value="Generuj PDF">';
$desc .= '<div id="div_desc" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
$lol="'index.php?to_pdf=1&module=EcmPrices&action=selectImages','images'";
$desc .=$mod_strings ['LBL_LANGS'] .' :<select tabindex="108" title="" id="langs" name="langs">
<option selected="selected" value="pl_pl" label="Polski">PL</option>
<option value="en_us" label="Angielski">US</option>
</select><br>';
$desc .= 'Pokaż zdjęcia: <input type="checkbox" value="1" id="images" name="images" onclick="mintajaxget('.$lol.');"/><br /><br />';
$desc .= '<input title="Pokaż PDF"
class="button"
onclick="location.href=\'index.php?module=EcmPrices&action=CreatePDF&record=' . $focus->id . '&to_pdf=1&disposition=D&images=\'+document.getElementById(\'images\').checked+\'&langs=\'+document.getElementById(\'langs\').value;"
type="button"
name="showpdf"
value="'.$mod_strings ['LBL_SHOW_PDF'] .'"></div>';
$xtpl->assign ("PDFGEN",$desc);
$desc='';
$desc.='<input title="'.$mod_strings ['LBL_SHOW_XLS2'] .'" class="button" onclick="if(document.getElementById(\'div_desc3\').style.display==\'none\')document.getElementById(\'div_desc3\').style.display=\'block\';else document.getElementById(\'div_desc3\').style.display=\'none\';" type="button" name="productcard" id="productcard" value="Generuj XLS">';
$desc .= '<div id="div_desc3" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
//$lol="'index.php?to_pdf=1&module=EcmPrices&action=selectImages','images'";
$desc .=$mod_strings ['LBL_LANGS'] .' :<select tabindex="108" title="" id="langs2" name="langs2">
<option selected="selected" value="pl_pl" label="Polski">PL</option>
<option value="en_us" label="Angielski">US</option>
</select><br>';
//$desc .= 'Pokaż zdjęcia: <input type="checkbox" value="1" id="images" name="images" onclick="mintajaxget('.$lol.');"/><br /><br />';
$desc.='<input value="'.$mod_strings ['LBL_SHOW_XLS'] .'"
class="button"
onclick="location.href=\'index.php?module=EcmPrices&amp;action=CreateXLS&amp;to_pdf=1&amp;disposition=D&langs2=\'+document.getElementById(\'langs2\').value;" type="button" >';
$xtpl->assign("GENXLS",$desc);
// $xtpl->assign("CATALOGUE",'<input type="button" class="button" value="Create Catalogue PL" onclick="location.href=\'index.php?module=EcmPrices&action=createCatalogue&language=pl&record='.$focus->id.'&to_pdf=1\';">&nbsp;<input type="button" class="button" value="Create Catalogue EN" onclick="location.href=\'index.php?module=EcmPrices&action=createCatalogue&language=en&record='.$focus->id.'&to_pdf=1\';">');
$detailView->processListNavigation ( $xtpl, "ECMPRICES", $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='EcmPrices'; 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 ( 'EcmPrices' )
) );
$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'];
?>

View File

@@ -0,0 +1,342 @@
<?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 EcmPrice 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 = 'EcmPrices';
var $table_name = "ecmprices";
var $object_name = "EcmPrice";
//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 EcmPrice() {
if(!$_REQUEST['isDuplicate'] && $_REQUEST['action']=="EditView")$_SESSION['pricebook_duplicate_id']="";
parent::SugarBean();
$this->setupCustomFields('EcmPrices');
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 .= "
ecmprices.*";
if($_REQUEST['pricebook_product_id'])$query.=" ,ecmprices_ecmproducts.price as price";
$query.=",users.user_name as assigned_user_name";
if($custom_join){
$query .= $custom_join['select'];
}
$query .= " FROM ecmprices
LEFT JOIN users
ON ecmprices.assigned_user_id=users.id";
if($_REQUEST['pricebook_product_id'])$query.=" LEFT JOIN ecmprices_ecmproducts
ON ecmprices_ecmproducts.ecmprice_id=ecmprices.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 ecmprices_ecmproducts.ecmproduct_id='".$_REQUEST['pricebook_product_id']."'";
//if($_REQUEST['exchange_rate_id'])$query.=" AND ecmprices.exchange_rate_id='".$_REQUEST['exchange_rate_id']."'";
if($_GET['pricebook_id'])$query.=" AND ecmprices.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 ecmprices.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 ecmprice_id from ecmprices_ecmproducts where deleted='0' and ecmproduct_id='".$_REQUEST['pricebook_product_id']."'");
while($r=$GLOBALS['db']->fetchByAssoc($w))$arr[]="ecmprices.id like '".$r['ecmprice_id']."'";
$wpr="( ".implode(" or ",$arr)." )";
}
$select = "SELECT ";
$select .= "ecmprices.*";
$select.=",users.user_name as assigned_user_name";
if($custom_join){
$select .= $custom_join['select'];
}
$from = " FROM ecmprices LEFT JOIN users ON ecmprices.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 ecmprices.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
ecmprices.*,
users.user_name assigned_user_name";
if($custom_join){
$query .= $custom_join['select'];
}
$query .= " FROM ecmprices ";
$query .= " LEFT JOIN users
ON ecmprices.assigned_user_id=users.id";
if($custom_join){
$query .= $custom_join['join'];
}
$query .= "";
$where_auto = " ecmprices.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 ecmprices.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,$current_user;
$the_array = parent::get_list_view_data();
$app_list_strings = return_app_list_strings_language($current_language);
$mod_strings = return_module_language($current_language, 'EcmPrices');
// 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 ecmprices 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 ecmprices_ecmproducts where ecmproduct_id='".$_REQUEST['pricebook_product_id']."' and ecmprice_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, "ecmprices.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("ECMPRICES_DESCRIPTION", $ecmprices->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);
}
}
?>

View 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/EcmPrices/EcmPrice.php');
require_once('include/javascript/javascript.php');
class EcmPricesQuickCreate extends QuickCreate {
var $javascript;
function process() {
global $current_user, $timedate, $app_list_strings, $current_language, $mod_strings;
$mod_strings = return_module_language($current_language, 'EcmPrices');
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(\"ecmpricesQuickCreate\")) return SUGAR.subpanelUtils.inlineSave(this.form.id, \"ecmprices\"); else return false;'");
$this->ss->assign('cancelOnclick', "onclick='return SUGAR.subpanelUtils.cancelCreate(\"subpanel_ecmprices\")';");
}
$this->ss->assign('viaAJAX', $this->viaAJAX);
$this->javascript = new javascript();
$this->javascript->setFormName('ecmpricesQuickCreate');
$focus = new EcmPrice();
$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' => 'ecmpricesQuickCreate',
'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);
}
}
?>

View File

@@ -0,0 +1,229 @@
<?
global $db;
$result = $db->query("select * from ecmprices_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/EcmPrices/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=EcmPrices&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" >&nbsp;</td>
<td width="35%" class="dataField">&nbsp;</td>
</tr>
<tr>
<td class="dataLabel"><span sugar='slot3'>Choose columns </span sugar='slot'></td>
<td class="dataField">&nbsp;</td>
<td valign="top" class="dataLabel">&nbsp;</td>
<td valign="top" class="dataField">&nbsp;</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">&nbsp;</td>
<td class="dataLabel" valign="top">&nbsp;</td>
<td class="dataField">&nbsp;</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">&nbsp;</td>
<td class="dataLabel" valign="top">&nbsp;</td>
<td class="dataField">&nbsp;</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>

View File

@@ -0,0 +1,152 @@
<!--
/*****************************************************************************
* 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.
********************************************************************************/
-->
<!-- BEGIN: main -->
<script type="text/javascript" src="include/javascript/popup_parent_helper.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<form name="EditView" method="POST" action="index.php">
<input type="hidden" name="module" value="EcmPrices">
<input type="hidden" name="record" value="{ID}">
<input type="hidden" name="action">
<input type="hidden" name="return_module" value="{RETURN_MODULE}">
<input type="hidden" name="return_id" value="{RETURN_ID}">
<input type="hidden" name="return_action" value="{RETURN_ACTION}">
<input type="hidden" name="contact_id" value="{CONTACT_ID}">
<input type="hidden" name="email_id" value="{EMAIL_ID}">
<input type="hidden" name="account_id" value="{ACCOUNT_ID}">
<input type="hidden" name="case_id" value="{CASE_ID}">
<!--// InboundEmail support //-->
<input type="hidden" name="inbound_email_id" value="{INBOUND_EMAIL_ID}">
<input type="hidden" name="start" value="{START}">
<input type="hidden" name="type" value="{TYPE}">
<td style="padding-bottom: 2px;">
<input title="{APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{APP.LBL_SAVE_BUTTON_KEY}" class="button"
onclick="this.form.action.value='Save';return check_form('EditView');"
type="submit" name="button" value=" {APP.LBL_SAVE_BUTTON_LABEL} " >
<input title="{APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{APP.LBL_CANCEL_BUTTON_KEY}" class="button"
onclick="this.form.action.value='{RETURN_ACTION}'; this.form.module.value='{RETURN_MODULE}'; this.form.record.value='{RETURN_ID}'"
type="submit" name="button" value=" {APP.LBL_CANCEL_BUTTON_LABEL} ">
</td>
<td align="right" nowrap><span class="required">{APP.LBL_REQUIRED_SYMBOL}</span> {APP.NTC_REQUIRED}</td>
<td align='right'>{ADMIN_EDIT}</td>
</tr>
</table>
<p>
<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'>{MOD.LBL_NAME} <span class="required">{APP.LBL_REQUIRED_SYMBOL}</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="{NAME}"></span sugar='slot'></td>
<td class="dataLabel" ><span sugar='slot2'>{APP.LBL_ASSIGNED_TO}</span sugar='slot'></td>
<td class="dataField">
<span sugar='slot2b'>
<input class="sqsEnabled" tabindex="2" autocomplete="off" id="assigned_user_name" name='assigned_user_name' type="text" value="{ASSIGNED_USER_NAME}">
<input id='assigned_user_id' name='assigned_user_id' type="hidden" value="{ASSIGNED_USER_ID}" />
<input title="{APP.LBL_SELECT_BUTTON_TITLE}" accessKey="{APP.LBL_SELECT_BUTTON_KEY}" type="button" class="button" value='{APP.LBL_SELECT_BUTTON_LABEL}' name=btn1
onclick='open_popup("Users", 600, 400, "", true, false, {encoded_users_popup_request_data});' /></span sugar='slot'> </td>
</tr>
<tr>
<td class="dataLabel"><span sugar='slot3'>{MOD.LBL_ACTIVE}</span sugar='slot'></td>
<td class="dataField">
<span sugar='slot3b'>
<input id="active" title="Product active" type="checkbox" title="{ACTIVE_HELP}" name="active" {ACTIVE}/></span sugar='slot'> </td>
<td valign="top" class="dataLabel"><span sugar='slot6'>{MOD.LBL_EXCHANGE_RATE_ID}</span sugar='slot'></td>
<td valign="top" class="dataField"><select name="exchange_rate_id" id="exchange_rate_id">
{EXCHANGE_RATE_ID}
</select> </td>
</tr>
<tr>
<td class="dataLabel" valign="top">{MOD.LBL_ACCOUNT_NAME}</td>
<td class="dataField"><input id='account_id' name='account_id' type="hidden" value="{ACCOUNT_ID}" />
<input class="sqsEnabled" id='account_name' name='account_name' type="text" tabindex='13' maxlength='40' value="{ACCOUNT_NAME}" />
</span sugar='slot'> <input title="{APP.LBL_SELECT_BUTTON_TITLE}" accesskey="{APP.LBL_SELECT_BUTTON_KEY}" type="button" class="button" value='{APP.LBL_SELECT_BUTTON_LABEL}' name="btn1"
onclick='open_popup("Accounts", 600, 400, "index.php?module=Accounts&action=Popup&mode=single&create=true&metadata=undefined", true, false, {encoded_accounts_popup_request_data});' /></td>
<td valign="top" class="dataLabel">{MOD.LBL_LEAD_NAME}</td>
<td valign="top" class="dataField"><input id='lead_id' name='lead_id' type="hidden" value="{LEAD_ID}" />
<input class="sqsEnabled" id='lead_name' name='lead_name' type="text" tabindex='13' maxlength='40' value="{LEAD_NAME}" />
</span sugar='slot'> <input title="{APP.LBL_SELECT_BUTTON_TITLE}" accesskey="{APP.LBL_SELECT_BUTTON_KEY}" type="button" class="button" value='{APP.LBL_SELECT_BUTTON_LABEL}' name="btn1"
onclick='open_popup("Leads", 600, 400, "index.php?module=Leads&action=Popup&mode=single&create=true&metadata=undefined", true, false, {encoded_leads_popup_request_data});' /></td>
</tr>
<tr>
<td class="dataLabel" valign="top"><span sugar='slot4'>{MOD.LBL_DESCRIPTION}</span sugar='slot'></td>
<td class="dataField"><span sugar='slot4b'>
<textarea name='description' title="Description" tabindex='4' cols="30" rows="4">{DESCRIPTION}</textarea>
</span sugar='slot'> </td>
<td valign="top" class="dataLabel">&nbsp;</td>
<td valign="top" class="dataField">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</p>
<div style="padding-top: 2px">
<input title="{APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{APP.LBL_SAVE_BUTTON_KEY}" class="button" onclick="this.form.action.value='Save';return check_form('EditView');" type="submit" name="button" value=" {APP.LBL_SAVE_BUTTON_LABEL} " >
<input title="{APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="this.form.action.value='{RETURN_ACTION}'; this.form.module.value='{RETURN_MODULE}'; this.form.record.value='{RETURN_ID}'" type="submit" name="button" value=" {APP.LBL_CANCEL_BUTTON_LABEL} ">
</div>
</form>
{JAVASCRIPT}
<!-- END: main -->

View 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/EcmPrices/EcmPrice.php');
require_once('modules/EcmPrices/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 EcmPrice();
// 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("EcmPrices detail view");
// ASSIGN XTEMPLATE
$xtpl = new XTemplate ('modules/EcmPrices/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('EcmPrices')));
$str = "<script>
YAHOO.util.Event.addListener(window, 'load', SUGAR.util.fillShortcuts, $savedSearchSelects);
</script>";
echo $str;
?>

1018
modules/EcmPrices/Email.js Normal file

File diff suppressed because it is too large Load Diff

View 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/EcmPrices/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/EcmPrices/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/EcmPrices/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('&lt;','&gt;');
$new = array('<','>');
if($_REQUEST['from_addr'] != $_REQUEST['from_addr_name'].' &lt;'.$_REQUEST['from_addr_email'].'&gt;') {
if(false === strpos($_REQUEST['from_addr'], '&lt;')) { // 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=EcmPrices&action=Emails&to_pdf=1&bodyclass=tabForm&type=out&pricebook_id=".$_REQUEST['pricebook_id']);
?>

View File

@@ -0,0 +1,371 @@
<!--
/**
* 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".
*/
-->
<!-- BEGIN: main -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="">
<title></title>
<script type="text/javascript" src="include/javascript/sugar_grp1_yui.js?s=5.0.0c&c="></script>
<script type="text/javascript" src="include/javascript/sugar_grp1.js?s=5.0.0c&c="></script>
<script type="text/javascript" src="include/javascript/sugar_3.js?s=5.0.0c&c="></script>
<script type="text/javascript" src="include/javascript/sugar_grp1.js?s=5.0.0c&c="></script>
<script type="text/javascript" src="jscalendar/lang/calendar-en.js?s=5.0.0c&c="></script>
<script type="text/javascript" src="include/SugarFields/Fields/Address/SugarFieldAddress.js?s=5.0.0c&c="></script>
<script type="text/javascript" src="cache/jsLanguage/en_us.js?s=5.0.0c&c=&j=1">
</script><script type="text/javascript" src="cache/jsLanguage/Accounts/en_us.js?s=5.0.0c&c=&j=1"></script>
<script type="text/javascript" src="jssource/src_files/include/SugarEmailAddress/SugarEmailAddress.js?s=5.0.0c&c="></script>
<link rel="stylesheet" type="text/css" href="themes/Sugar/navigation.css?s=5.0.0c&c=" />
<link rel="stylesheet" type="text/css" href="themes/Sugar/style.css?s=5.0.0c&c=" />
<link rel="stylesheet" type="text/css" href="themes/Sugar/colors.sugar.css?s=5.0.0c&c=" id="current_color_style" />
<link rel="stylesheet" type="text/css" href="themes/Sugar/fonts.normal.css?s=5.0.0c&c=" id="current_font_style"/>
<script language="javascript" src="themes/default/SiteMapJS.js?s=5.0.0c&c="></script>
<script language="javascript" src="themes/menu.js?s=5.0.0c&c="></script>
<script language="javascript" src="themes/cookie.js?s=5.0.0c&c="></script>
<script language="javascript" src="themes/Sugar/style.js?s=5.0.0c&c="></script>
<script language="javascript" src="include/JSON.js?s=5.0.0c&c="></script>
<script type="text/javascript" language="Javascript">
{JS_VARS}
</script>
</head>
<body class="{BODYCLASS}" style="border:none;" onLoad="">
<script type="text/javascript" src="include/jsolait/init.js?s={SUGAR_VERSION}&amp;c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="include/javascript/jsclass_base.js?s={SUGAR_VERSION}&amp;c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="include/javascript/jsclass_async.js?s={SUGAR_VERSION}&amp;c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="modules/EcmPrices/Email.js?s={SUGAR_VERSION}&amp;c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="modules/Documents/documents.js?s={SUGAR_VERSION}&amp;c={JS_CUSTOM_VERSION}"></script>
{MESSAGE}
<form action="index.php" method="post" name="EditView" enctype="multipart/form-data">
<input type="hidden" name="module" value="EcmPrices" />
<input type="hidden" name="action" value="EmailSave" />
<input type="hidden" name="to_pdf" value="1" />
<input type="hidden" name="contact_id" value="{CONTACT_ID}" />
<input type="hidden" name="user_id" value="{USER_ID}" />
<input type="hidden" name="return_module" value="{RETURN_MODULE}" />
<input type="hidden" name="return_id" value="{RETURN_ID}" />
<input type="hidden" name="send" value="" />
<input type="hidden" name="type" value="out" />
<input type="hidden" name="record" value="{ID}" />
<input type="hidden" name="return_action" value="{RETURN_ACTION}" />
<input type="hidden" name="inbound_email_id" value="{INBOUND_EMAIL_ID}" />
<input type="hidden" name="assigned_user_id" value="{ASSIGNED_USER_ID}" />
<input type="hidden" name="object_type" value="{OBJECT_TYPE}" />
<input type="hidden" name="object_id" value="{OBJECT_ID}" />
<input type="hidden" name="group" value="{GROUP}" />
<input type="hidden" name="origType" value="{TYPE}" />
<input type="hidden" name="invoiceout_id" value="{INVOICEOUT_ID}" />
<input type="hidden" name="pricebook_id" value="{PRICEBOOK_ID}" />
<input type="hidden" name="pIdFrom" value="{PIDFROM}" />
<input type="hidden" name="pTypeFrom" value="{PTYPEFROM}" />
<input type="hidden" name="pIdTo" value="{PIDTO}" />
<input type="hidden" name="pTypeTo" value="{PTYPETO}" />
<input type="hidden" name="bodyclass" value="{BODYCLASS}" />
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<th class="dataLabel" align="left" colspan="8">
<h4>Send email</h4><br>
</th>
<tr>
<td style="padding-bottom: 2px;">
<input type="submit" name="button" class="button" {disable_send} title="{MOD.LBL_SEND_BUTTON_TITLE}" accesskey="{MOD.LBL_SEND_BUTTON_KEY}" value=" {MOD.LBL_SEND_BUTTON_LABEL} " />
<!--
<input type="submit" name="button" class="button" title="{MOD.LBL_SAVE_AS_DRAFT_BUTTON_TITLE}" accesskey="{MOD.LBL_SAVE_AS_DRAFT_BUTTON_KEY}" value=" {MOD.LBL_SAVE_AS_DRAFT_BUTTON_LABEL} " onclick="return invoiceoutAlert('save_draft');" />
<input type="submit" name="button" class="button" title="{APP.LBL_CANCEL_BUTTON_TITLE}" accesskey="{APP.LBL_CANCEL_BUTTON_KEY}" value=" {APP.LBL_CANCEL_BUTTON_LABEL} " onclick="this.form.action.value='{RETURN_ACTION}'; this.form.module.value='{RETURN_MODULE}'; this.form.record.value='{RETURN_ID}'; {MYINBOX}" />
-->
</td>
<td align="right" nowrap>
</td>
<td align='right'>
{ADMIN_EDIT}
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- BEGIN: open_source_1 -->
<td nowrap class="dataLabel">
<slot> </slot>
Attach PDF </td>
<td nowrap>
<slot> </slot> </td>
<!-- END: open_source_1 -->
<td nowrap>
<slot> </slot> </td>
<td>
<div style="display:none;">
<slot>
<select tabindex='2' name='parent_type' onChange=" document.EditView.parent_name.value='';
changeQS();
checkParentType(document.EditView.parent_type.value, document.EditView.change_parent);">
{TYPE_OPTIONS}</select>&nbsp; </slot>
</div>
<input type="checkbox" name="attach_pdf" value="1" checked>
Images:
<input type="checkbox" name="email_images" value="true" checked></td>
<td class="dataField" nowrap>
<div style="display:none;">
<slot>
<input id='parent_id' name='parent_id' type="hidden" value='{PARENT_ID}'>
<input class="sqsEnabled" id='parent_name' name='parent_name' tabindex='2' type='text' value="{PARENT_NAME}">
&nbsp;{CHANGE_PARENT_BUTTON} </slot>
</div> </td>
</tr>
<tr>
<td class="dataLabel">
<div style="display:none;">
<slot>
{APP.LBL_ASSIGNED_TO}&nbsp; </slot>
</div>
Attach XLS </td>
<td class="dataField">
<div style="display:none;">
<slot>
<input class="sqsEnabled" tabindex='1' id="assigned_user_name" name='assigned_user_name' type="text" value="{ASSIGNED_USER_NAME}">
<input id='assigned_user_id' name='assigned_user_id' type="hidden" value="{ASSIGNED_USER_ID}" />
<input title="{APP.LBL_SELECT_BUTTON_TITLE}" accesskey="{APP.LBL_SELECT_BUTTON_KEY}" type="button" tabindex='1' class="button" value='{APP.LBL_SELECT_BUTTON_LABEL}' name="btn1" onclick='open_popup("Users", 600, 400, "", true, false, {encoded_users_popup_request_data});' />
</slot>
</div> </td>
<td nowrap>
<slot> </slot> </td>
<td nowrap>
<slot> </slot>
<span class="dataLabel">
<input type="checkbox" name="attach_xls" value="checkbox">
</span></td>
<td nowrap>
<slot> </slot> </td>
</tr>
<tr>
<td colspan="5">&nbsp; </td>
</tr>
<tr>
<td colspan="1">&nbsp; </td>
<td colspan="4">
{MOD.LBL_NOTE_SEMICOLON} </td>
<td colspan="2">&nbsp; </td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_TO} </slot> </td>
<td colspan="4" class="dataField" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="to_addrs_field" name='to_addrs' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{TO_ADDRS}">{TO_ADDRS}</textarea>
<input type="hidden" id="to_addrs_ids" name="to_addrs_ids" value="{TO_ADDRS_IDS}" />
<input type="hidden" id="to_addrs_emails" name="to_addrs_emails" value="{TO_ADDRS_EMAILS}" />
<input type="hidden" id="to_addrs_names" name="to_addrs_names" value="{TO_ADDRS_NAMES}" /> </td>
<td style="padding-left: 4px;">
{CHANGE_TO_ADDRS_BUTTON} </td>
</tr>
</table>
</slot> </td>
</tr>
<tr>
<td class="dataLabel">
<slot>
{MOD.LBL_CC} </slot> </td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="cc_addrs_field" name='cc_addrs' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{CC_ADDRS}">{CC_ADDRS}</textarea>
<input type="hidden" id="cc_addrs_ids" name="cc_addrs_ids" value="{CC_ADDRS_IDS}" />
<input type="hidden" id="cc_addrs_emails" name="cc_addrs_emails" value="{CC_ADDRS_EMAILS}" />
<input type="hidden" id="cc_addrs_names" name="cc_addrs_names" value="{CC_ADDRS_NAMES}" /> </td>
<td style="padding-left: 4px;">
{CHANGE_CC_ADDRS_BUTTON} </td>
</tr>
</table>
</slot> </td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_BCC} </slot> </td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="bcc_addrs_field" name='bcc_addrs' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{BCC_ADDRS}">{BCC_ADDRS}</textarea>
<input type="hidden" id="bcc_addrs_ids" name="bcc_addrs_ids" value="{BCC_ADDRS_IDS}" />
<input type="hidden" id="bcc_addrs_emails" name="bcc_addrs_emails" value="{BCC_ADDRS_EMAILS}" />
<input type="hidden" id="bcc_addrs_names" name="bcc_addrs_names" value="{BCC_ADDRS_NAMES}" /> </td>
<td style="padding-left: 4px;">
{CHANGE_BCC_ADDRS_BUTTON} </td>
</tr>
</table> </td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_FROM} </slot> </td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="from_addr_field" name='from_addr' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{FROM_ADDR}">{FROM_ADDR}</textarea> {FROM_ADDR_GROUP}
<input type="hidden" id="from_addr_email" name="from_addr_email" />
<input type="hidden" id="from_addr_name" name="from_addr_name" /> </td>
</tr>
</table>
</slot> </td>
</tr>
<tr>
<td colspan="5">&nbsp; </td>
</tr>
<tr>
<td class="dataLabel">
<slot>
{MOD.LBL_SUBJECT} </slot> </td>
<td colspan='4' class="dataField">
<slot>
<textarea name='name' tabindex='4' cols="100" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" id="subjectfield">{NAME}</textarea>
</slot> </td>
</tr>
<tr>
<td valign="top" class="dataLabel">
{MOD.LBL_BODY} </td>
<!-- BEGIN: htmlarea -->
<td colspan="2" class="dataField">
<div style="display:none;">
<slot>
<div id="editor_select">
<input id="setEditor" name="setEditor" value="1" {EMAIL_EDITOR_OPTION} type="checkbox" onClick="toggle_textonly();" />
{MOD.LBL_EMAIL_EDITOR_OPTION} </div>
</slot>
</div> </td>
<td class="dataLabel" valign="top">
<slot>
{MOD.LBL_USE_TEMPLATE}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select tabindex='2' name='email_template' onChange="fill_email(this.options[this.selectedIndex].value);">
{EMAIL_TEMPLATE_OPTIONS}
</select>
&nbsp;&nbsp;
<input type="button" class="button" name="clear" id="clear" value="Clear" onClick="fill_email('');">
&nbsp;&nbsp;
<input type="button" class="button" name="new_template" id="new_template" value="Template Fields" onClick="document.getElementById('template_fields').style.display='';" />
</slot> </td>
<td class="dataField" nowrap width="1">
<slot> </slot> </td>
</tr>
<tr>
<td></td>
<td colspan="4">
<div id="template_fields" style="display:none">
<table>
<tr>
<td valign="top" class="dataLabel">
Templatate Fields: </td>
<td colspan="5" class="dataField">
<slot>
{MFP}
<input type="button" class="button" name="cancel_template_fields" id="cancel_template_fields" value="Hide" onClick="document.getElementById('template_fields').style.display='none';">
</slot> </td>
</tr>
</table>
</div> </td>
</tr>
<tr>
<td valign="top" class="dataLabel">&nbsp; </td>
<td colspan="4" class="dataField">
{TINY}
<slot>
<div style="display:none;">
<div id="html_div">
<textarea id="description_html" onBlur="">{DESCRIPTION_HTML}</textarea>
</div>
</div>
<div style="display:none;">
<div id="alt_text_div">
<input id="toggle_textarea_elem" onClick="toggle_textarea();" type="checkbox" name="toggle_html">
{MOD.LBL_EDIT_ALT_TEXT} </div>
</div>
<div id="text_div" style="display: none;"> </div>
<textarea tabindex='5' id="description" name='description' cols="100" rows="20">{DESCRIPTION}</textarea>
</slot> </td>
<!-- END: htmlarea -->
</tr>
</table>
</td>
</tr>
</table>
</form>
{JAVASCRIPT}
</body>
</html>
<!-- END: main -->

View 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/EcmPrices/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 = '&nbsp;<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/EcmPrices/EcmPrice.php');
$m = new EcmPrice();
//$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}'>&nbsp;";
$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/EcmPrices/Forms.php Normal file
View 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('EcmPrices', '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="EcmPriceSave" onSubmit="return check_form('EcmPricesSave')" method="POST" action="index.php">
<input type="hidden" name="module" value="EcmPrices">
<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}&nbsp;<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/EcmPrices/EcmPrice.php');
$javascript = new javascript();
$javascript->setFormName('EcmPricesSave}');
$javascript->setSugarBean(new EcmPrice());
$javascript->addRequiredFields('');
$the_form .= $javascript->getScript();
$the_form .= get_left_form_footer();
return $the_form;
}
?>

View 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=EcmPrices&action=ListViewProductsAjax&customview_id='.$_GET['customview_id'].'&pricebook_id='.$_REQUEST['pricebook_id'].'&order_by='.$order_by.'&sorder='.$s.'\',\'products\');">'.$title.'&nbsp;'.$img.'</a>';
}
?>

View 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/EcmPrices/EcmPrice.php');
require_once('modules/EcmPrices/Forms.php');
require_once ('include/time.php');
require_once('include/json_config.php');
$json_config = new json_config();
$focus = new EcmPrice();
if(isset($_REQUEST['record'])) {
$focus->retrieve($_REQUEST['record']);
}
else {}
require_once('include/MVC/View/SugarView.php');
if(file_exists('modules/EcmPrices/views/view.list.php')) {
require_once('modules/EcmPrices/views/view.list.php');
$list = new EcmPricesViewList();
}
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();
?>

View File

@@ -0,0 +1,98 @@
<!--
/*****************************************************************************
* 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.
********************************************************************************/
-->
<!-- BEGIN: main -->
<table cellpadding="0" cellspacing="0" width="100%" border="0" class="listView">
<!-- BEGIN: list_nav_row -->
{PAGINATION}
<!-- END: list_nav_row -->
<tr height="20">
<td scope="col" class="listViewThS1" NOWRAP>{CHECKALL}</td>
<td scope="col" width="32%" class="listViewThS1" NOWRAP><slot><a href="{ORDER_BY}name" class="listViewThLinkS1">{MOD.LBL_LIST_SUBJECT}{arrow_start}{name_arrow}{arrow_end}</a></slot></td>
<!-- BEGIN: pro_nav -->
<td scope="col" width="9%" class="listViewThS1" NOWRAP><slot><a href="{ORDER_BY}teams.name" class="listViewThLinkS1">{APP.LBL_LIST_TEAM}{arrow_start}{teams_name_arrow}{arrow_end}</a></slot></td>
<!-- END: pro_nav -->
<!-- BEGIN: open_source -->
<!-- END: open_source -->
<td scope="col" width="9%" class="listViewThS1" NOWRAP><slot><a href="{ORDER_BY}users.user_name" class="listViewThLinkS1">{APP.LBL_LIST_ASSIGNED_USER}{arrow_start}{users_user_name_arrow}{arrow_end}</a></slot></td>
</tr>
<!-- BEGIN: row -->
<tr height="20"
onmouseover="setPointer(this, '{ECMPRICE.NAME}', 'over', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');"
onmouseout="setPointer(this, '{ECMPRICE.NAME}', 'out', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');"
onmousedown="setPointer(this, '{ECMPRICE.NAME}', 'click', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');">
<td class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}" valign='top'>{PREROW}</td>
<td scope='row' valign=TOP class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}">
<slot>
<{TAG.MAIN} href="{URL_PREFIX}index.php?action=DetailView&module=EcmPrices&record={ECMPRICE.ID}&offset={ECMPRICE.OFFSET}&stamp={ECMPRICE.STAMP}" class="listViewTdLinkS1">{ECMPRICE.NAME}</{TAG.MAIN}>
</slot>
</td>
<!-- BEGIN: pro -->
<td valign=TOP class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}" nowrap><slot>{ECMPRICE.TEAM_NAME}</slot></td>
<!-- END: pro -->
<!-- BEGIN: open_source -->
<!-- END: open_source -->
<td valign=TOP class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}" nowrap><slot>{ECMPRICE.ASSIGNED_USER_NAME}</slot></td>
</tr>
<tr><td colspan="20" class="listViewHRS1"></td></tr>
<!-- END: row -->
{PAGINATION}
</table>
<!-- END: main -->

View 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;
?>

View 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">&nbsp;</td>
<td valign="top" class="dataField">&nbsp;</td>
<td valign="top" class="dataLabel">&nbsp;</td>
<td valign="top" class="dataField">&nbsp;</td>
<td valign="top" class="dataLabel">&nbsp;</td>
<td valign="top" class="dataField">&nbsp;</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'];?> &nbsp;</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=EcmPrices&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">&nbsp;</td>
</tr>
<tr>
</table>
<div id="list"></div>
<script language="javascript">mintajaxget('index.php?to_pdf=1&pricebook_id=<?print $_REQUEST['pricebook_id'];?>&module=EcmPrices&action=ListViewAddToPriceBookAjax','list');</script>

View File

@@ -0,0 +1,86 @@
<?
require_once("modules/EcmPrices/ListHelper.php");
$_COOKIE['pricebook_id']=$_REQUEST['pricebook_id'];
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,id from ecmprices 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 ecmprices where id='".$_COOKIE['pricebook_id']."'"));
$name=$r['name'];
$exchange_rate_id=$r['exchange_rate_id'];
$t=array("&nbsp;",$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="EcmPrices">';
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 ecmprices_ecmproducts where deleted='0' and ecmprice_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=EcmPrices&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 ecmprices_ecmproducts where ecmprice_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>';
?>

View File

@@ -0,0 +1,73 @@
<?
require_once("modules/EcmPrices/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 ecmprices 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 ecmprices_customview where id='".$_REQUEST['customview_id']."'");
$row=$GLOBALS['db']->fetchByAssoc($result);
$t=array("&nbsp;",$mod_strings['LBL_PRODUCT_NAME'],$mod_strings['LBL_PRICEBOOK_NAME'],$mod_strings['LBL_PURCHASE_PRICE'],$mod_strings['LBL_LIST_PRICE'], "&nbsp;");
$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="EcmPrices">';
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 ecmprices 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=EcmPrices&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 ecmprices_ecmproducts where ecmproduct_id='".$_REQUEST['product_id']."' and ecmprice_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>';
?>

View File

@@ -0,0 +1,438 @@
<?
set_time_limit(50);
require_once("modules/EcmPrices/ListHelper.php");
//$GLOBALS['db']->query("SET NAMES 'utf8' COLLATE 'utf8_polish_ci'");
$result = $GLOBALS['db']->query("select * from ecmprices_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[]="ecmprices_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 ecmprices 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 ecmprices_ecmproducts.price as price,ecmprices_ecmproducts.id as idp,ecmproducts.* from ecmprices_ecmproducts left join ecmproducts on ecmproducts.id=ecmprices_ecmproducts.ecmproduct_id where ecmprices_ecmproducts.ecmprice_id='".$_COOKIE['pricebook_id']."' and ecmprices_ecmproducts.deleted='0'");
$checkc='';
$checkc.='if(document.getElementById(\'checkin\').checked==true)
{
mintajaxget(\'index.php?to_pdf=1&module=EcmPrices&action=checkAllProducts&pricebook_id='.$_REQUEST['pricebook_id'].'&value=true\',\'checkin\');
}
else
{
mintajaxget(\'index.php?to_pdf=1&module=EcmPrices&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
ecmprices_ecmproducts.price as price,
ecmprices_ecmproducts.popular as popular,
ecmprices_ecmproducts.recipient_code as recipient_code,
ecmprices_ecmproducts.id as idp,
ecmprices_ecmproducts.margin_rate,
ecmprices_ecmproducts.position as position,
ecmprices_ecmproducts.remarks_pl as remarks_pl,
ecmprices_ecmproducts.remarks_en as remarks_en,
ecmprices_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 ecmprices_ecmproducts
left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id
left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id
left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id
inner join ecmproducts on ecmproducts.id=ecmprices_ecmproducts.ecmproduct_id
where ecmprices_ecmproducts.ecmprice_id='".$_REQUEST['pricebook_id']."' and ecmprices_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=EcmPrices&action=updatePrices&record='.$_REQUEST['pricebook_id'].'" method="post">
Marża:&nbsp<input id="margin" name="margin" type="text" value="0"/>&nbsp
Rabat:&nbsp<input id="discount" name="discount" type="text" value="0"/>&nbsp
Cena z VAT:&nbsp<input id="with_tax" name="with_tax" type="checkbox"/>&nbsp
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=EcmPrices&action=SavePrices&record='.$_REQUEST['pricebook_id'].'" method="post">';
print '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="list view" border="1"><tr>';
print '<td class="listViewThS1" width="2%"><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("ecmprices_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="ecmprices_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="ecmprices_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="ecmprices_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="ecmprices_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%">&nbsp;</td>';
print '<td class="listViewThS1" width="1%">&nbsp;</td>';
print '<td class="listViewThS1" width="1%">&nbsp;</td>';
}
$stop[$row['code']]=false;
$sale30="";
$qty30="";
$sale90="";
$qty90="";
$sale180="";
$qty180="";
if($_SESSION['EcmPrices_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=EcmPrices&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" style="text-align: left">'.($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" style="text-align: left">';
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 '&nbsp;<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=EcmPrices&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=EcmPrices&action=DeleteFromPriceBook&but=1&return_id='.$_COOKIE['pricebook_id'].'\';"></div>';
?>

View File

@@ -0,0 +1,58 @@
<?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 $mod_strings;
$module="EcmPrices";
if(ACLController::checkAccess($module, 'edit', true))$module_menu [] = Array("index.php?module=".$module."&action=EditView&return_module=".$module."&return_action=DetailView", $mod_strings['LNK_NEW_'.strtoupper($module)],"Create".$module,$module);
if(ACLController::checkAccess($module, 'list', true))$module_menu [] = Array("index.php?module=".$module."&action=index&return_module=".$module."&return_action=DetailView", $mod_strings['LNK_'.strtoupper($module).'_LIST'],$module, $module);
?>

View File

@@ -0,0 +1,5 @@
<?
session_start();
$_SESSION['pricebook_images']=$_REQUEST['images'];
header("Location: modules/EcmPrices/CreatePDF.php");
?>

View File

@@ -0,0 +1,122 @@
<!--
/*****************************************************************************
* 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.
********************************************************************************/
-->
<!-- BEGIN: main -->
<!-- BEGIN: SearchHeader -->
{SET_RETURN_JS}
<script type="text/javascript">
function toggleDisplay(id){
if(this.document.getElementById( id).style.display=='none'){
this.document.getElementById( id).style.display='inline'
if(this.document.getElementById(id+"link") != undefined){
this.document.getElementById(id+"link").style.display='none';
}
}else{
this.document.getElementById( id).style.display='none'
if(this.document.getElementById(id+"link") != undefined){
this.document.getElementById(id+"link").style.display='inline';
}
}
}
</script>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="tabForm">
<tr>
<td>
<div id='divsearchform' style='display:inline'>
<form>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="dataLabel" nowrap="nowrap" width="40%">{MOD.LBL_NAME}&nbsp;&nbsp;<input type="text" size="20" name="name" class="dataField" value="{NAME}" /></td>
<td width="10%" align="right">
<input type="hidden" name="action" value="Popup" />
<input type="hidden" name="query" value="true"/>
<input type="hidden" name="module" value="{MODULE_NAME}" />
<input type="hidden" name="parent_id" value="{parent_id}" />
<input type="hidden" name="parent_name" value="{parent_name}" />
<input type="submit" name="button" class="button"
title="{APP.LBL_SEARCH_BUTTON_TITLE}"
accesskey="{APP.LBL_SEARCH_BUTTON_KEY}"
value="{APP.LBL_SEARCH_BUTTON_LABEL}" />
</td>
</tr>
</table>
</form>
</div>
</td>
</tr>
</table>
<!-- END: SearchHeader -->
<!-- BEGIN: SearchHeaderEnd -->
<!-- END: SearchHeaderEnd -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="listView">
<!-- BEGIN: list_nav_row -->
{PAGINATION}
<!-- END: list_nav_row -->
<tr height="20">
<td scope="col" width="65%" class="listViewThS1"><a href="{ORDER_BY}name" class="listViewThLinkS1">{MOD.LBL_LIST_NAME}{arrow_start}{name_arrow}{arrow_end}</a></td>
<td scope="col" width="35%" class="listViewThS1"><a href="{ORDER_BY}assigned_user_name" class="listViewThLinkS1">{MOD.LBL_LIST_ASSIGNED_USER_ID}{arrow_start}{assigned_user_name_arrow}{arrow_end}</a></td>
</tr>
<!-- BEGIN: row -->
<tr height="20"
onmouseover="setPointer(this, '{ecmprices.ID}', 'over', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');"
onmouseout ="setPointer(this, '{ecmprices.ID}', 'out', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');"
onmousedown="setPointer(this, '{ecmprices.ID}', 'click', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');">
<td scope='row' class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}"><a href="#" onclick="set_return('{.ID}', '{ecmprices.NAME}'); window.close();" class="listViewTdLinkS1">{ecmprices.NAME}</a></td>
<td class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}">{ecmprices.ASSIGNED_USER_NAME}</td>
</tr>
<tr>
<td colspan="20" class="listViewHRS1"></td>
</tr>
<!-- END: row -->
</table>
<!-- END: main -->

View 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/EcmPrices/Popup_picker.php');
$popup = new Popup_Picker();
echo $popup->process_page();
?>

View File

@@ -0,0 +1,165 @@
<!--
/*****************************************************************************
* 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.
********************************************************************************/
-->
<!-- BEGIN: main -->
<!-- BEGIN: SearchHeader -->
<script type="text/javascript" src="include/JSON.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="include/javascript/popup_helper.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="tabForm">
<tr>
<td>
<form action="index.php" method="post" name="popup_query_form" id="the_form">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%" nowrap="nowrap" class="dataLabel">{MOD.LBL_NAME}&nbsp;&nbsp;
<input type="text" name="name" size="20" class="dataField" value="{NAME}" /></td>
<td width="20%" align="right">
<input type="hidden" name="module" value="{MODULE_NAME}" />
<input type="hidden" name="action" value="Popup" />
<input type="hidden" name="query" value="true" />
<input type="hidden" name="request_data" value="{request_data}" />
<input type="hidden" name="record_id" value="" />
<input type="hidden" name="pricebook_product_id" value="{PRICEBOOK_PRODUCT_ID}" />
<input type="hidden" name="exchange_rate_id" value="{EXCHANGE_RATE_ID}" />
<input type="submit" name="button" class="button"
title="{APP.LBL_SEARCH_BUTTON_TITLE}"
accessKey="{APP.LBL_SEARCH_BUTTON_KEY}"
value="{APP.LBL_SEARCH_BUTTON_LABEL}" />
<input type="hidden" name="mode" value="{MULTI_SELECT}" />
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
/* initialize the popup request from the parent */
if(window.document.forms['popup_query_form'].request_data.value == "")
{
window.document.forms['popup_query_form'].request_data.value
= JSON.stringify(window.opener.get_popup_request_data());
}
function send_back1(module,id)
{var associated_row_data=associated_javascript_data[id];eval("var temp_request_data = "+window.document.forms['popup_query_form'].request_data.value);if(temp_request_data.jsonObject){var request_data=temp_request_data.jsonObject;}else{var request_data=temp_request_data;}
var passthru_data=Object();if(typeof(request_data.passthru_data)!='undefined')
{passthru_data=request_data.passthru_data;}
var form_name=request_data.form_name;var field_to_name_array=request_data.field_to_name_array;var call_back_function=eval("window.opener."+request_data.call_back_function);var array_contents=Array();for(var the_key in field_to_name_array)
{if(the_key!='toJSON')
{var the_name=field_to_name_array[the_key];var the_value='';if(module!=''&&id!='')
{the_value=associated_row_data[the_key.toUpperCase()];}
if(typeof(the_value)=='string'){the_value=the_value.replace(/\r\n/g,'\\n');}
array_contents.push('"'+the_name+'":"'+the_value+'"');}}
eval("var name_to_value_array = {"+array_contents.join(",")+"}");var result_data={"form_name":form_name,"name_to_value_array":name_to_value_array,"passthru_data":passthru_data};var close_popup=window.opener.get_close_popup();call_back_function(result_data);
for(var i=0; i<parent.opener.N.rowCount(); i++)
{
parent.opener.N.row(i).calculateTotal();
};if(close_popup){window.close();}}
-->
</script>
<!-- END: SearchHeader -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="listView">
<!-- BEGIN: list_nav_row -->
{PAGINATION}
<!-- END: list_nav_row -->
<tr height="20" class="listViewThS1">
<td scope="col" width="30%" class="listViewThS1" NOWRAP>
<slot>
<a href="{ORDER_BY}name" class="listViewThLinkS1">{MOD.LBL_NAME}{arrow_start}{name_arrow}{arrow_end}</a>
</slot>
</td>
<td scope="col" width="13%" class="listViewThS1" NOWRAP>Index</td>
<td scope="col" width="13%" class="listViewThS1" NOWRAP>
<slot>
<a href="{ORDER_BY}exchange_rate_id" class="listViewThLinkS1">{MOD.LBL_EXCHANGE_RATE_ID}{arrow_start}{exchange_rate_id_arrow}{arrow_end}</a>
</slot>
</td>
<td scope="col" width="30%" class="listViewThS1" NOWRAP>
<slot>
<a href="{ORDER_BY}account_name" class="listViewThLinkS1">{MOD.LBL_ACCOUNT_NAME}{arrow_start}{account_name_arrow}{arrow_end}</a>
</slot>
</td>
<td scope="col" width="13%" class="listViewThS1" NOWRAP>List Price</td>
</tr>
<!-- BEGIN: row -->
<tr height="20"
onmouseover="setPointer(this, '{ECMPRICE.ID}', 'over', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');"
onmouseout="setPointer(this, '{ECMPRICE.ID}', 'out', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');"
onmousedown="setPointer(this, '{ECMPRICE.ID}', 'click', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');">
<td scope="row" valign="top" class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}">
<slot>
<{TAG.MAIN} href="#"
onclick="send_back1('EcmPrice','{ECMPRICE.ID}');"
class="listViewTdLinkS1">{ECMPRICE.NAME}</{TAG.MAIN}>
</slot>
</td>
<td scope="row" valign="top" class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}">{ECMPRICE.INDEX}</td>
<td scope="row" valign="top" class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}">{ECMPRICE.EXCHANGE_RATE_NAME}</td>
<td scope="row" valign="top" class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}">{ECMPRICE.ACCOUNT_NAME}</td>
<td scope="row" valign="top" class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}">{ECMPRICE.PRICE}</td>
</tr>
<tr>
<td colspan="24" class="listViewHRS1"></td>
</tr>
<!-- END: row -->
</table>
{ASSOCIATED_JAVASCRIPT_DATA}
<!-- END: main -->

View 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/EcmPrices/EcmPrice.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", "ecmprices.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/EcmPrices/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 EcmPrice();
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select price from ecmprices_ecmproducts where ecmproduct_id='".$_REQUEST['pricebook_product_id']."' and ecmprice_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', 'ECMPRICE');
$ListView->setModStrings($mod_strings);
ob_start();
$ListView->processListView($seed_bean, 'main', 'ECMPRICE');
$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/EcmPrices/Save.php Normal file
View 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/EcmPrices/EcmPrice.php');
require_once('include/formbase.php');
$focus = new EcmPrice();
$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 ecmprices 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 ecmprices_ecmproducts where ecmprice_id='".$_SESSION['pricebook_duplicate_id']."'");
$_SESSION['pricebook_duplicate_id']="";
while($r=$GLOBALS['db']->fetchByAssoc($w)) {
$GLOBALS['db']->query("insert into ecmprices_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,'EcmPrices');
?>

View 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 ecmprices_customview set name='".$_REQUEST['name']."',columns='".$columns."',titles='".$titles."',orders='".$orders."' where id='".$_REQUEST['record']."'");
else $db->query("insert into ecmprices_customview values('".create_guid()."','".$_REQUEST['name']."','".$columns."','".$titles."','".$orders."')");
header("Location: index.php?module=EcmPrices&action=DetailView&record=".$_SESSION['pricebook_id']."&tab=items");
?>

View 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=EcmPrices&action=DetailView&record=".$_REQUEST['record']."&tab=items");
?>

View 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 ecmprices_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 ecmprice_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 ecmprices_ecmproducts where ecmproduct_id='".$_REQUEST['record']."' and ecmprice_id='".$_REQUEST['pricebook_id']."'"));
$_SESSION['EcmPrices_high'][$r['id']]=true;
include("modules/EcmPrices/ListViewProductsAjax.php");
?>

View 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 ecmprices_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 ecmprices_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['EcmPrices_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 ecmprice_id from ecmprices_ecmproducts where id='".$prod."'"));
header("Location: index.php?module=EcmPrices&action=DetailView&record=".$r['ecmprice_id']."&tab=items");
?>

View File

@@ -0,0 +1,102 @@
<!--
/*****************************************************************************
* 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.
********************************************************************************/
-->
<!-- BEGIN: main -->
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="border-top: 0px none; margin-bottom: 4px" class="tabForm">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="25%" noWrap class="dataLabel">
<span sugar='slot1'>{MOD.LBL_NAME}</span sugar='slot'> </td>
<td width="25%" valign="top" class="dataField">
<span sugar='slot1b'>
<input type=text size="30" name="name_basic" class=dataField value="{NAME}" />
</span sugar='slot'> </td>
<td width="25%" class="dataLabel">{APP.LBL_CURRENT_USER_FILTER}&nbsp;&nbsp; </td>
<td width="25%" class="dataLabel"><input name='current_user_only_basic' onchange='this.form.submit();' class="checkbox" type="checkbox" {CURRENT_USER_ONLY}></td>
</tr>
<tr>
<td width="15%" class="dataLabel" valign="top"><span sugar='slot3'>{MOD.LBL_DESCRIPTION}</span sugar='slot'></td>
<td width="25%" class="dataField">
<span sugar='slot3b'>
<input name="description_basic" type="text" tabindex="3" title="Description" value="{DESCRIPTION}" size="30" />
</span sugar='slot'> </td>
</table>
</td>
</tr>
</table>
<!-- END: main -->
<!-- BEGIN: advanced -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-top: 0px none; margin-bottom: 4px" class="tabForm">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="25%" valign="top" class="dataLabel"><span sugar='slot1'>{MOD.LBL_NAME}</span sugar='slot'></td>
<td width="25%" valign="top" class="dataField"><span sugar='slot1b'><input name='name' type="text" tabindex='1' size='30' maxlength='50' value="{NAME}"></span sugar='slot'></td>
<td width="25%" valign="top" class="dataLabel"><span sugar='slot2'>{APP.LBL_ASSIGNED_TO}</span sugar='slot'></td>
<td width="25%" valign="top" class="dataField"><span sugar='slot2b'><select tabindex='1' style="width: 150px" size='3' name='assigned_user_id[]' multiple="multiple">{USER_FILTER}</select></span sugar='slot'></td>
<tr>
<td width="25%" class="dataLabel" valign="top"><span sugar='slot1'>{MOD.LBL_DESCRIPTION}</span sugar='slot'></td>
<td width="25%" class="dataField">
<span sugar='slot1b'>
<input name="description" type="text" tabindex="1" title="Description" value="{DESCRIPTION}" size="30" />
</span sugar='slot'> </td>
</tr>
</table>
</td>
</tr>
</table>
<!-- END: advanced -->

View File

@@ -0,0 +1,89 @@
<!--
/*****************************************************************************
* 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.
********************************************************************************/
-->
<!-- BEGIN: main -->
<table cellpadding="0" cellspacing="0" width="100%" border="0" class="listView">
<tr height="20" >
<td scope="col" width="5%" class="listViewThS1"><slot>{MOD.LBL_LIST_NUMBER}</slot></td>
<td scope="col" width="50%" class="listViewThS1"><slot>{MOD.LBL_LIST_SUBJECT}</slot></td>
<td scope="col" width="15%" class="listViewThS1"><slot>{MOD.LBL_LIST_STATUS}</slot></td>
<td scope="col" width="5%" class="listViewThS1"><slot>&nbsp;</slot></td>
<td scope="col" width="50%" class="listViewThS1"><slot>{MOD.LBL_LIST_NAME}</slot></td>
</tr>
<!-- BEGIN: row -->
<tr height="20" onmouseover="setPointer(this, '{ECMPRICES.ID}', 'over', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');"
onmouseout="setPointer(this, '{ECMPRICES.ID}', 'out', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');"
onmousedown="setPointer(this, '{ECMPRICES.ID}', 'click', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');">
<td scope='row' valign=TOP bgcolor="{BG_COLOR}" class="{ROW_COLOR}S1" ><slot>{ECMPRICES.NUMBER}</slot></td>
<td valign=TOP bgcolor="{BG_COLOR}" class="{ROW_COLOR}S1" ><slot>
<a href="{URL_PREFIX}index.php?action=DetailView&module=EcmPrices&record={ECMPRICES.ID}" class="listViewTdLinkS1">{ECMPRICES.NAME}</a></slot>
</td>
<td valign=TOP bgcolor="{BG_COLOR}" class="{ROW_COLOR}S1" ><slot>{ECMPRICES.STATUS}</slot></td>
<td nowrap align="center" valign=TOP bgcolor="{BG_COLOR}" class="{ROW_COLOR}S1" >
<slot>
<a class="listViewTdToolsS1" href="{URL_PREFIX}index.php?action=EditView&module=EcmPrices&record={ECMPRICES.ID}{RETURN_URL}">{EDIT_INLINE_PNG}</a>&nbsp;
<a class="listViewTdToolsS1" href="{URL_PREFIX}index.php?action=EditView&module=EcmPrices&record={ECMPRICES.ID}{RETURN_URL}">{APP.LNK_EDIT}</a>
</slot>
</td>
<td scope='row' valign=TOP bgcolor="{BG_COLOR}" class="{ROW_COLOR}S1" ><slot>{ECMPRICES.NAME}</slot></td>
<td valign=TOP bgcolor="{BG_COLOR}" class="{ROW_COLOR}S1" >
<slot>
<a href="{URL_PREFIX}index.php?action=DetailView&module=EcmPrices&record={ECMPRICES.ID}" class="listViewTdLinkS1">{ECMPRICES.NAME}</a>
</slot>
</td>
</tr>
<tr>
<td colspan="20" class="listViewHRS1"></td>
</tr>
<!-- END: row -->
</table>
<!-- END: main -->

View 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, 'EcmPrices');
$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' => 'ecmprice_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='EcmPrices'>\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(\"EcmPrices\", 600, 400, \"\", false, true, {$encoded_popup_request_data});'>\n";
$button .= "</form>\n";
$ListView = new ListView();
$ListView->initNewXTemplate( 'modules/EcmPrices/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 = "&nbsp;<a href='index.php?action=index&module=DynamicLayout&from_action=SubPanelView&from_module=EcmPrices&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", "ECMPRICE");
?>

View File

@@ -0,0 +1,23 @@
<?
$result = $GLOBALS['db']->query("select name,id from ecmprices 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 ecmprices_ecmproducts where ecmprice_id='".$_REQUEST['pricebook_id'][$i]."' and ecmproduct_id='".$_REQUEST['product_id']."'");
if(mysql_num_rows($w)==0)
{
$GLOBALS['db']->query("insert into ecmprices_ecmproducts(id,ecmprice_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 ecmprices_ecmproducts set price='".$_REQUEST['list_price_'.$_REQUEST['pricebook_id'][$i]]."' where ecmprice_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']);
?>

View File

@@ -0,0 +1,4 @@
<?
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: inline; filename=\"../../cache/upload/".$_REQUEST['file']."\"");
?>

View File

@@ -0,0 +1,480 @@
/*
* AdvancedAJAX 1.1.2
* (c) 2005-2006 Lukasz Lach
* mail: anakin@php5.pl
* www: http://advajax.anakin.us/
* http://anakin.us/
* http://creativecommons.org/licenses/LGPL/2.1/
*
*/
function advAJAX() {
var obj = new Object();
obj.url = window.location.href;
obj.method = "GET";
obj.parameters = new Object();
obj.jsonParameters = new Object();
obj.headers = new Object();
obj.async = true;
obj.mimeType = "text/xml";
obj.username = null;
obj.password = null;
obj.form = null;
obj.disableForm = true;
obj.unique = true;
obj.uniqueParameter = "_uniqid";
obj.requestDone = false;
obj.queryString = "";
obj.responseText = null;
obj.responseXML = null;
obj.status = null;
obj.statusText = null;
obj.aborted = false;
obj.timeout = 0;
obj.retryCount = 0;
obj.retryDelay = 1000;
obj.tag = null;
obj.group = null;
obj.progressTimerInterval = 50;
obj.xmlHttpRequest = null;
obj.onInitialization = null;
obj.onFinalization = null;
obj.onReadyStateChange = null;
obj.onLoading = null;
obj.onLoaded = null;
obj.onInteractive = null;
obj.onComplete = null;
obj.onProgress = null;
obj.onSuccess = null;
obj.onFatalError = null;
obj.onError = null;
obj.onTimeout = null;
obj.onRetryDelay = null;
obj.onRetry = null;
obj.onGroupEnter = null;
obj.onGroupLeave = null;
obj.createXmlHttpRequest = function() {
if (typeof XMLHttpRequest != "undefined")
return new XMLHttpRequest();
var xhrVersion = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",
"MSXML2.XMLHttp","Microsoft.XMLHttp" ];
for (var i = 0; i < xhrVersion.length; i++) {
try {
var xhrObj = new ActiveXObject(xhrVersion[i]);
return xhrObj;
} catch (e) { }
}
obj.raiseEvent("FatalError");
return null;
};
obj._oldResponseLength = null;
obj._progressTimer = null;
obj._progressStarted = navigator.userAgent.indexOf('Opera') == -1;
obj._onProgress = function() {
if (typeof obj.onProgress == "function" &&
typeof obj.xmlHttpRequest.getResponseHeader == "function") {
var contentLength = obj.xmlHttpRequest.getResponseHeader("Content-length");
if (contentLength != null && contentLength != '') {
var responseLength = obj.xmlHttpRequest.responseText.length;
if (responseLength != obj._oldResponseLength) {
obj.raiseEvent("Progress", obj, responseLength, contentLength);
obj._oldResponseLength = obj.xmlHttpRequest.responseText.length;
}
}
}
if (obj._progressStarted) return;
obj._progressStarted = true;
var _obj = this;
this.__onProgress = function() {
obj._onProgress();
obj._progressTimer = window.setTimeout(_obj.__onProgress, obj.progressTimerInterval);
}
_obj.__onProgress();
}
obj._onInitializationHandled = false;
obj._initObject = function() {
if (obj.xmlHttpRequest != null) {
delete obj.xmlHttpRequest["onreadystatechange"];
obj.xmlHttpRequest = null;
}
if ((obj.xmlHttpRequest = obj.createXmlHttpRequest()) == null)
return null;
if (typeof obj.xmlHttpRequest.overrideMimeType != "undefined")
obj.xmlHttpRequest.overrideMimeType(obj.mimeType);
obj.xmlHttpRequest.onreadystatechange = function() {
if (obj == null || obj.xmlHttpRequest == null)
return;
obj.raiseEvent("ReadyStateChange", obj, obj.xmlHttpRequest.readyState);
obj._onProgress();
switch (obj.xmlHttpRequest.readyState) {
case 1: obj._onLoading(); break;
case 2: obj._onLoaded(); break;
case 3: obj._onInteractive(); break;
case 4: obj._onComplete(); break;
}
};
obj._onLoadingHandled =
obj._onLoadedHandled =
obj._onInteractiveHandled =
obj._onCompleteHandled = false;
};
obj._onLoading = function() {
if (obj._onLoadingHandled)
return;
if (!obj._retry && obj.group != null) {
if (typeof advAJAX._groupData[obj.group] == "undefined")
advAJAX._groupData[obj.group] = 0;
advAJAX._groupData[obj.group]++;
if (typeof obj.onGroupEnter == "function" && advAJAX._groupData[obj.group] == 1)
obj.onGroupEnter(obj);
}
obj.raiseEvent("Loading", obj);
obj._onLoadingHandled = true;
};
obj._onLoaded = function() {
if (obj._onLoadedHandled)
return;
obj.raiseEvent("Loaded", obj);
obj._onLoadedHandled = true;
};
obj._onInteractive = function() {
if (obj._onInteractiveHandled)
return;
obj.raiseEvent("Interactive", obj);
obj._onInteractiveHandled = true;
if (!obj._progressStarted)
obj._onProgress();
};
obj._onComplete = function() {
if (obj._onCompleteHandled || obj.aborted)
return;
if (obj._progressStarted) {
window.clearInterval(obj._progressTimer);
obj._progressStarted = false;
}
obj.requestDone = true;
with (obj.xmlHttpRequest) {
obj.responseText = responseText;
obj.responseXML = responseXML;
if (typeof status != "undefined")
obj.status = status;
if (typeof statusText != "undefined")
obj.statusText = statusText;
}
obj.raiseEvent("Complete", obj);
obj._onCompleteHandled = true;
if (obj.status == 200)
obj.raiseEvent("Success", obj); else
obj.raiseEvent("Error", obj);
delete obj.xmlHttpRequest['onreadystatechange'];
obj.xmlHttpRequest = null;
if (obj.disableForm)
obj.switchForm(true);
obj._groupLeave();
obj.raiseEvent("Finalization", obj);
};
obj._groupLeave = function() {
if (obj.group != null) {
advAJAX._groupData[obj.group]--;
if (advAJAX._groupData[obj.group] == 0)
obj.raiseEvent("GroupLeave", obj);
}
};
obj._retry = false;
obj._retryNo = 0;
obj._onTimeout = function() {
if (obj == null || obj.xmlHttpRequest == null || obj._onCompleteHandled)
return;
obj.aborted = true;
obj.xmlHttpRequest.abort();
obj.raiseEvent("Timeout", obj);
obj._retry = true;
if (obj._retryNo != obj.retryCount) {
obj._initObject();
if (obj.retryDelay > 0) {
obj.raiseEvent("RetryDelay", obj);
startTime = new Date().getTime();
while (new Date().getTime() - startTime < obj.retryDelay);
}
obj._retryNo++;
obj.raiseEvent("Retry", obj, obj._retryNo);
obj.run();
} else {
delete obj.xmlHttpRequest["onreadystatechange"];
obj.xmlHttpRequest = null;
if (obj.disableForm)
obj.switchForm(true);
obj._groupLeave();
obj.raiseEvent("Finalization", obj);
}
};
obj.run = function() {
obj._initObject();
if (obj.xmlHttpRequest == null)
return false;
obj.aborted = false;
if (!obj._onInitializationHandled) {
obj.raiseEvent("Initialization", obj);
obj._onInitializationHandled = true;
}
if (obj.method == "GET" && obj.unique)
obj.parameters[encodeURIComponent(obj.uniqueParameter)] =
new Date().getTime().toString().substr(5) + Math.floor(Math.random() * 100).toString();
if (!obj._retry) {
for (var a in obj.parameters) {
if (obj.queryString.length > 0)
obj.queryString += "&";
if (typeof obj.parameters[a] != "object")
obj.queryString += encodeURIComponent(a) + "=" + encodeURIComponent(obj.parameters[a]); else {
for (var i = 0; i < obj.parameters[a].length; i++)
obj.queryString += encodeURIComponent(a) + "=" + encodeURIComponent(obj.parameters[a][i]) + "&";
obj.queryString = obj.queryString.slice(0, -1);
}
}
for (var a in obj.jsonParameters) {
var useJson = typeof [].toJSONString == 'function';
if (obj.queryString.length > 0)
obj.queryString += "&";
obj.queryString += encodeURIComponent(a) + "=";
if (useJson)
obj.queryString += encodeURIComponent(obj.jsonParameters[a].toJSONString()); else
obj.queryString += encodeURIComponent(obj.jsonParameters[a]);
}
if (obj.method == "GET" && obj.queryString.length > 0)
obj.url += (obj.url.indexOf("?") != -1 ? "&" : "?") + obj.queryString;
}
if (obj.disableForm)
obj.switchForm(false);
try {
obj.xmlHttpRequest.open(obj.method, obj.url, obj.async, obj.username || '', obj.password || '');
} catch (e) {
obj.raiseEvent("FatalError", obj, e);
return;
}
if (obj.timeout > 0)
setTimeout(obj._onTimeout, obj.timeout);
if (typeof obj.xmlHttpRequest.setRequestHeader != "undefined")
for (var a in obj.headers)
obj.xmlHttpRequest.setRequestHeader(encodeURIComponent(a), encodeURIComponent(obj.headers[a]));
if (obj.method == "POST" && typeof obj.xmlHttpRequest.setRequestHeader != "undefined") {
obj.xmlHttpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
obj.xmlHttpRequest.send(obj.queryString);
} else if (obj.method == "GET")
obj.xmlHttpRequest.send('');
};
obj.handleArguments = function(args) {
if (typeof args.form == "object" && args.form != null) {
obj.form = args.form;
obj.appendForm();
}
for (a in args) {
if (typeof obj[a] == "undefined")
obj.parameters[a] = args[a]; else {
if (a != "parameters" && a != "headers")
obj[a] = args[a]; else
for (b in args[a])
obj[a][b] = args[a][b];
}
}
obj.method = obj.method.toUpperCase();
};
obj.switchForm = function(enable) {
if (typeof obj.form != "object" || obj.form == null)
return;
with (obj.form)
for (var nr = 0; nr < elements.length; nr++)
if (!enable) {
if (elements[nr]["disabled"])
elements[nr]["_disabled"] = true; else
elements[nr]["disabled"] = "disabled";
} else
if (typeof elements[nr]["_disabled"] == "undefined")
elements[nr].removeAttribute("disabled");
};
obj.appendForm = function() {
with (obj.form) {
obj.method = getAttribute("method").toUpperCase();
obj.url = getAttribute("action");
for (var nr = 0; nr < elements.length; nr++) {
var e = elements[nr];
if (e.disabled)
continue;
switch (e.type) {
case "text":
case "password":
case "hidden":
case "textarea":
obj.addParameter(e.name, e.value);
break;
case "select-one":
if (e.selectedIndex >= 0)
obj.addParameter(e.name, e.options[e.selectedIndex].value);
break;
case "select-multiple":
for (var nr2 = 0; nr2 < e.options.length; nr2++)
if (e.options[nr2].selected)
obj.addParameter(e.name, e.options[nr2].value);
break;
case "checkbox":
case "radio":
if (e.checked)
obj.addParameter(e.name, e.value);
break;
}
}
}
};
obj.addParameter = function(name, value) {
if (typeof obj.parameters[name] == "undefined")
obj.parameters[name] = value; else
if (typeof obj.parameters[name] != "object")
obj.parameters[name] = [ obj.parameters[name], value ]; else
obj.parameters[name][obj.parameters[name].length] = value;
};
obj.delParameter = function(name) {
delete obj.parameters[name];
};
obj.raiseEvent = function(name) {
var args = [];
for (var i = 1; i < arguments.length; i++)
args.push(arguments[i]);
if (typeof obj["on" + name] == "function")
obj["on" + name].apply(null, args);
if (name == "FatalError")
obj.raiseEvent("Finalization", obj);
}
if (typeof advAJAX._defaultParameters != "undefined")
obj.handleArguments(advAJAX._defaultParameters);
return obj;
}
advAJAX.get = function(args) {
return advAJAX.handleRequest("GET", args);
};
advAJAX.post = function(args) {
return advAJAX.handleRequest("POST", args);
};
advAJAX.head = function(args) {
return advAJAX.handleRequest("HEAD", args);
};
advAJAX.submit = function(form, args) {
if (typeof args == "undefined" || args == null)
return -1;
if (typeof form != "object" || form == null)
return -2;
var request = new advAJAX();
args["form"] = form;
request.handleArguments(args);
return request.run();
};
advAJAX.assign = function(form, args) {
if (typeof args == "undefined" || args == null)
return -1;
if (typeof form != "object" || form == null)
return -2;
if (typeof form["onsubmit"] == "function")
form["_onsubmit"] = form["onsubmit"];
form["advajax_args"] = args;
form["onsubmit"] = function() {
if (typeof this["_onsubmit"] != "undefined" && this["_onsubmit"]() === false)
return false;
if (advAJAX.submit(this, this["advajax_args"]) == false)
return true;
return false;
}
return true;
};
advAJAX.download = function(targetObj, url) {
if (typeof targetObj == "string")
targetObj = document.getElementById(targetObj);
if (!targetObj)
return -1;
advAJAX.get({
url: url,
onSuccess : function(obj) {
targetObj.innerHTML = obj.responseText;
}
});
};
advAJAX.scan = function() {
var obj = document.getElementsByTagName("a");
for (var i = 0; i < obj.length;) {
if (obj[i].getAttribute("rel") == "advancedajax" && obj[i].getAttribute("href") !== null) {
var url = obj[i].getAttribute("href");
var div = document.createElement("div");
div.innerHTML = obj[i].innerHTML;
div.className = obj[i].className;
var parent = obj[i].parentNode;
parent.insertBefore(div, obj[i]);
parent.removeChild(obj[i]);
advAJAX.download(div, url);
} else i++;
}
};
advAJAX.handleRequest = function(requestType, args) {
if (typeof args == "undefined" || args == null)
return -1;
var request = new advAJAX();
window.advajax_obj = request;
request.method = requestType;
request.handleArguments(args);
return request.run();
};
advAJAX._defaultParameters = new Object();
advAJAX.setDefaultParameters = function(args) {
advAJAX._defaultParameters = new Object();
for (a in args)
advAJAX._defaultParameters[a] = args[a];
};
advAJAX._groupData = new Object();

View File

@@ -0,0 +1,114 @@
<?
if($_REQUEST['reset']==1){
$GLOBALS['db']->query("delete from ecmprices_ecmproducts_categories_sort where ecmprice_id='".$_REQUEST['record']."'");
header("Location: index.php?module=EcmPrices&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 ecmprices_ecmproducts_categories_sort where ecmprice_id='".$_REQUEST['record']."'");
for($i=1;$i<=count($boxy);$i++){
$z="insert into ecmprices_ecmproducts_categories_sort set id='".create_guid()."',position='".$i."',ecmprice_id='".$_REQUEST['record']."',category_id='".$boxy[$i-1]."'";
$GLOBALS['db']->query($z);
//echo $z.'<br>';;
}
header("Location: index.php?module=EcmPrices&action=productsOrder&record=".$_REQUEST['record']);
}
?>
<script type="text/javascript" src="modules/EcmPrices/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 ecmprices where id='".$_REQUEST['record']."'";
$w=$GLOBALS['db']->query($z);
$r=$GLOBALS['db']->fetchByAssoc($w);
print "&nbsp;".$r['name'];
?>
</h2></td>
</tr></table>
<form action="index.php?module=EcmPrices&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=EcmPrices&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
$w = $GLOBALS['db']->query("select id from ecmprices_ecmproducts_categories_sort where ecmprice_id='".$_REQUEST['record']."'");
if ($w->num_rows==0)
$z="select id from ecmproductcategories where deleted='0' order by name asc";
else
$z="select position,category_id as id from ecmprices_ecmproducts_categories_sort where ecmprice_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>

View 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 ecmprices_ecmproducts as e inner join ecmproducts as p on p.id=e.ecmproduct_id where e.ecmprice_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=EcmPrices&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>';
}
}
?>

View File

@@ -0,0 +1,10 @@
<?
$result = $GLOBALS['db']->query("select id from ecmprices_ecmproducts where ecmprice_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'];
?>

View File

@@ -0,0 +1,4 @@
<?
$_SESSION['pricebook_check'][$_REQUEST['pricebook_id']][$_GET['record']]=$_GET['value'];
print $_GET['value'];
?>

View File

@@ -0,0 +1,28 @@
<?php
$from = "e2c0a18d-7c8d-cb0e-46ff-5305e3df9d9c";
$to = "a5089802-f543-237f-c7fa-53316fafe922";
$db = $GLOBALS['db'];
$db->query("DELETE FROM ecmprices_ecmproducts WHERE ecmprice_id='$to'");
$res = $db->query("SELECT * FROM ecmpricebooks_ecmproducts WHERE ecmpricebook_id='$from' AND deleted='0'");
while ($row = $db->fetchByAssoc($res)) {
$id = create_guid();
$new[] = $id;
$tmp = array();
$tmp[] = $id;
$tmp[] = $to;
$tmp[] = $row['ecmproduct_id'];
$tmp[] = round(floatval($row['price'])/4,2);
$query = "INSERT INTO ecmprices_ecmproducts (".implode(",", $fields).") VALUES ('".implode("','", $tmp)."')";
$db->query($query);
}
echo 'OK';
?>

View 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="ecmprices_ecmproducts.id='9999999999999999' and ";
}
else $where="i.id='9999999999999999' and ";
$w=$GLOBALS['db']->query("select i.ecmproduct_id from ecmprices_ecmproducts as i inner join ecmproducts as p on p.id=i.ecmproduct_id where ".$where." i.ecmprice_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");
?>

View File

@@ -0,0 +1,6 @@
<?
if($_REQUEST['id']){
if($GLOBALS['db']->query("update ecmprices_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";
}
?>

View File

@@ -0,0 +1,7 @@
<?php
$e=explode("|",$_REQUEST['keys']);
foreach($e as $ee){
$GLOBALS['db']->query("update ecmprices_ecmproducts set date_modified='".date("Y-m-d H:i:s")."',modified_user_id='".$_SESSION['authenticated_user_id']."',deleted='1' where id='".$ee."' and ecmprice_id='".$_REQUEST['return_id']."'");
}
header("Location: index.php?module=EcmPrices&action=DetailView&record=".$_REQUEST['return_id']."&tab=items");
?>

425
modules/EcmPrices/excel.php Normal file
View 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 */
?>

View 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['EcmPrice'] = 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
),
);
?>

View 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 ecmprices ".$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;
?>

View File

@@ -0,0 +1,12 @@
<?
$GLOBALS['db']->query("truncate table ecmprices");
$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 ecmprices 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>";
}
?>

View File

@@ -0,0 +1,9 @@
<?
$GLOBALS['db']->query("truncate table ecmprices_ecmproducts");
$w=$GLOBALS['db']->query("select * from pricebookproductrel");
while($r=$GLOBALS['db']->fetchByAssoc($w)) {
if($GLOBALS['db']->query("insert into ecmprices_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>";
}
?>

View File

@@ -0,0 +1,6 @@
<?php
global $current_user;
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('modules/EcmPrices/ListView.php');
?>

View File

@@ -0,0 +1,183 @@
<?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 name',
'LBL_UPDATE'=>'Update',
'LBL_LIST_PRICE' => 'B2B Price',
'LBL_ACCOUNT_NAME' => 'Account',
// FOR SYSTEM USE
'LBL_MODULE_NAME' => 'B2B Prices',
'LBL_MODULE_TITLE' => 'B2B Prices: Home',
'LBL_MODULE_ID' => 'B2B Prices',
'LBL_SEARCH_FORM_TITLE' => 'B2B Prices Search',
'LBL_LIST_FORM_TITLE' => 'B2B Prices List',
'LBL_NEW_FORM_TITLE' => 'New B2B Price',
'LBL_ECMPRICES' => 'B2B Prices:',
'LBL_ECMPRICES_SUBJECT' => 'B2B Prices Subject:',
'LBL_SYSTEM_ID' => 'System ID',
'LBL_LANGS' => 'Language',
'LBL_SHOW_XLS'=>'Show XLS',
'LBL_SHOW_XLS2'=>'Generate XLS',
'LBL_SHOW_PDF'=>'Generate PDF',
'LBL_LIST_PRICE_NAME_A' => 'Show price',
'LBL_IMAGE_S'=>'Show image',
// FOR LIST VIEW
'LBL_LIST_NAME' => 'Name',
'LBL_LIST_SUBJECT' => 'Subject',
'LBL_LIST_LAST_MODIFIED' => 'Last Modified',
'LBL_LIST_MY_ECMPRICES' => '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 ecmprice 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 ecmprice from this account?',
'ERR_DELETE_RECORD' => 'A record number must be specified to delete the ecmprice.',
// 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_ECMPRICES_SUBPANEL_TITLE' => 'Price Books',
'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Activities',
'LBL_HISTORY_SUBPANEL_TITLE' => 'History',
'LBL_ECMPRICES' => 'Price Books',
// FOR MENU LABELS
'LNK_NEW_ECMPRICES' => 'Create B2B Price',
'LNK_LIST_ECMPRICE' => 'B2B Prices List',
// FOR MENU LINKS
'LNK_NEW_ECMPRICE' => 'Create Price Books',
'LNK_ECMPRICES_LIST' => 'Price Books',
'LNK_ECMPRICES_REPORTS' => 'Price Books Reports',
// FOR ADDITIONAL MENUS
// FOR DASHLETS
'LBL_LIST_ECMPRICES' => 'Price Books',
);
?>

View File

@@ -0,0 +1,184 @@
<?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_LIST_PRICE_NAME_A' => 'Pokaż Cene',
'LBL_CURRENCY_VALUE'=>'Cena',
// added 19.01.2009
'LBL_REMARKS_PL'=>'Uwagi PL',
'LBL_REMARKS_EN'=>'Uwagi EN',
'LBL_REMARKS_DE'=>'Uwagi DE',
'LBL_LANGS' => 'Język',
'LBL_IMAGE_S'=>'Pokaż zdjęcie',
'LBL_SHOW_XLS'=>'Pokaż XLS',
'LBL_SHOW_XLS2'=>'Generuj XLS',
'LBL_SHOW_PDF'=>'Generuj PDF',
// 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 B2B',
'LBL_ACCOUNT_NAME' => 'Firma',
// FOR SYSTEM USE
'LBL_MODULE_NAME' => 'Ceny B2B',
'LBL_MODULE_TITLE' => 'Ceny B2B: Strona Glówna',
'LBL_MODULE_ID' => 'Ceny B2B',
'LBL_SEARCH_FORM_TITLE' => 'Wyszukaj',
'LBL_LIST_FORM_TITLE' => 'Lista Cen B2B',
'LBL_NEW_FORM_TITLE' => 'Nowa Cena B2B',
'LBL_ECMPRICES' => 'Ceny B2B:',
'LBL_ECMPRICES_SUBJECT' => 'Nazwa Ceny B2B:',
'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_ECMPRICES' => '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'=> 'Cena: 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_ECMPRICES_SUBPANEL_TITLE' => 'Cenniki',
'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Aktywnosci',
'LBL_HISTORY_SUBPANEL_TITLE' => 'Historia',
'LBL_ECMPRICES' => 'Cenny',
// FOR MENU LABELS
'LNK_NEW_ECMPRICES' => 'Utwórz Cenę B2B',
'LNK_LIST_ECMPRICE' => 'Lista Cen B2B',
// FOR MENU LINKS
'LNK_NEW_ECMPRICE' => 'Utwórz Cennik',
'LNK_ECMPRICES_LIST' => 'Ceny B2B',
'LNK_ECMPRICES_REPORTS' => 'Raport Cenników',
// FOR ADDITIONAL MENUS
// FOR DASHLETS
'LBL_LIST_ECMPRICES' => 'Cenniki',
);
?>

View 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['EcmPrices'] = array(
//LIST OF WHAT SUBPANELS TO SHOW IN THE DETAILVIEW
'subpanel_setup' => array(
),
);
?>

View 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['EcmPrices'] =
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'),
);
?>

View 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 additionalDetailsEcmPrice($fields) {
static $mod_strings;
global $app_strings;
if(empty($mod_strings)) {
global $current_language;
$mod_strings = return_module_language($current_language, 'EcmPrices');
}
$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=EcmPrices&return_module=EcmPrices&record={$fields['ID']}",
'viewLink' => "index.php?action=DetailView&module=EcmPrices&return_module=EcmPrices&record={$fields['ID']}");
}
?>

View File

@@ -0,0 +1,55 @@
<?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['EcmPrices']['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('exchange_rate_id', 'description'),
),
),
);
?>

View File

@@ -0,0 +1,80 @@
<?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['EcmPrices'] = array(
'NAME' => array(
'width' => '20',
'label' => 'LBL_NAME',
'default' => true,
'link' => 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')
);
?>

View 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' => 'EcmPrice',
'varName' => 'ECMPRICE',
'orderBy' => 'ecmprices.name',
'whereClauses' => array(
'name' => 'ecmprices.name',
'exchange_rate_id' => 'ecmprices.exchange_rate_id',
'account_id' => 'ecmprices.account_id',
),
'searchInputs' => array('name', 'name')
);
?>

View 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['EcmPrices'] = 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']),
),
),
);
?>

View 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']['EcmPrices'] = array(
'LBL_DETAILVIEW'=>array(
'template' => 'xtpl',
'template_file' => 'modules/EcmPrices/DetailView.html',
'php_file' => 'modules/EcmPrices/DetailView.php',
'type' => 'DetailView',
),
'LBL_EDITVIEW'=>array(
'template' => 'xtpl',
'template_file' => 'modules/EcmPrices/EditView.html',
'php_file' => 'modules/EcmPrices/EditView.php',
'type' => 'EditView',
),
'LBL_LISTVIEW'=>array(
'template' => 'listview',
'meta_file' => 'modules/EcmPrices/listviewdefs.php',
'type' => 'ListView',
),
'LBL_SEARCHFORM'=>array(
'template' => 'xtpl',
'template_file' => 'modules/EcmPrices/SearchForm.html',
'php_file' => 'modules/EcmPrices/ListView.php',
'type' => 'SearchForm',
),
);

View 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' => 'EcmPrices',
'width' => '4%',
),
'remove_button'=>array(
'widget_class' => 'SubPanelRemoveButton',
'module' => 'EcmPrices',
'width' => '5%',
),
),
);
?>

View 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' => 'EcmPrices'),
),
'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' => 'EcmPrices',
'width' => '4%',
),
'remove_button'=>array(
'widget_class' => 'SubPanelRemoveButton',
'module' => 'EcmPrices',
'width' => '5%',
),
),
);
?>

File diff suppressed because one or more lines are too long

5308
modules/EcmPrices/moo1.2.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,118 @@
<?
if($_REQUEST['reset']==1){
$GLOBALS['db']->query("update ecmprices_ecmproducts set position=0 where ecmprice_id='".$_REQUEST['record']."'");
header("Location: index.php?module=EcmPrices&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 ecmprices_ecmproducts set position='".$i."' where deleted='0' and ecmproduct_id='".$boxy[$i-1]."' and ecmprice_id='".$_REQUEST['record']."'";
$GLOBALS['db']->query($z);
}
header("Location: index.php?module=EcmPrices&action=DetailView&record=".$_REQUEST['record']);
}
$z="select id from ecmprices_ecmproducts where ecmprice_id='".$_REQUEST['record']."' and deleted='0'";
$w=$GLOBALS['db']->query($z);
$ile=mysql_num_rows($w);
?>
<script type="text/javascript" src="modules/EcmPrices/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 ecmprices where id='".$_REQUEST['record']."'";
$w=$GLOBALS['db']->query($z);
$r=$GLOBALS['db']->fetchByAssoc($w);
print "&nbsp;".$r['name'];
?>
</h2></td>
</tr></table>
<form action="index.php?module=EcmPrices&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=EcmPrices&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=EcmPrices&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 ecmprices_ecmproducts_categories_sort where ecmprice_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 ecmprices_ecmproducts_categories_sort where ecmprice_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 ecmprices_ecmproducts as e inner join ecmproducts as p on p.id=e.ecmproduct_id where e.ecmprice_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>

View 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 ecmprices_ecmproducts set position='".$i."' where deleted='0' and ecmproduct_id='".$boxy[$i-1]."' and ecmprice_id='".$_REQUEST['record']."'";
if($GLOBALS['db']->query($z))$ok=1;
else $error="Error";
}
if($error)print $error;
else print "Saved";
exit;
?>

View 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";
?>

View 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=EcmPrices&action=Emails&to_pdf=1&bodyclass=tabForm&type=out&pricebook_id=<?print $seid;?>'>Yours browser not accept iframes!</iframe>

View File

@@ -0,0 +1 @@
<iframe style='border:none;width:100%;height:500px;' frameborder='no' src='index.php?module=EcmPrices&action=CreatePDF&to_pdf=1&disposition=I&images=<?print $_REQUEST['images'];?>'>Yours browser not accept iframes!</iframe>

View File

@@ -0,0 +1 @@
<iframe style='border:none;width:100%;height:1200px;' frameborder='no' src='index.php?module=EcmPrices&action=CreateXLS&to_pdf=1&disposition=D'>Yours browser not accept iframes!</iframe>

View File

@@ -0,0 +1,5 @@
<?
$w=$GLOBALS['db']->query("select recipient_code,ecmproduct_id,ecmprice_id from ecmprices_ecmproducts where recipient_code!='' and recipient_code IS NOT NULL");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
print "update ecmprices_ecmproducts set recipient_code='".$r['recipient_code']."' where ecmproduct_id='".$r['ecmproduct_id']."' and ecmprice_id='".$r['ecmprice_id']."';<br>";
}

View 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' => 'EcmPrices'),
),
'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' => 'EcmPrices',
'width' => '4%',
),
'remove_button'=>array(
'widget_class' => 'SubPanelRemoveButton',
'module' => 'EcmPrices',
'width' => '5%',
),
),
);
?>

View File

@@ -0,0 +1,59 @@
<form name="ecmpricesQuickCreate" id="ecmpricesQuickCreate" method="POST" action="index.php">
<input type="hidden" name="module" value="EcmPrices">
<input type="hidden" name="return_action" value="{$REQUEST.return_action}">
<input type="hidden" name="return_module" value="{$REQUEST.return_module}">
<input type="hidden" name="return_id" value="{$REQUEST.return_id}">
<input type="hidden" name="action" value='Save'>
<input type="hidden" name="duplicate_parent_id" value="{$REQUEST.duplicate_parent_id}">
<input type="hidden" name="to_pdf" value='1'>
<input id='assigned_user_id' name='assigned_user_id' type="hidden" value="{$ASSIGNED_USER_ID}" />
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" style="padding-bottom: 2px;">
<input title= "{$APP.LBL_SAVE_BUTTON_TITLE}"
accessKey= "{$APP.LBL_SAVE_BUTTON_KEY}"
class= "button"
type= "submit"
name= "button" {$saveOnclick|default:"onclick=\"return check_form('EcmPricesQuickCreate');\""} value=" {$APP.LBL_SAVE_BUTTON_LABEL} " >
<input title= "{$APP.LBL_CANCEL_BUTTON_TITLE}"
accessKey= "{$APP.LBL_CANCEL_BUTTON_KEY}"
class= "button"
type= "submit"
name= "button" {$cancelOnclick|default:"onclick=\"this.form.action.value='$RETURN_ACTION'; this.form.module.value='$RETURN_MODULE'; this.form.record.value='$RETURN_ID'\""}
value= " {$APP.LBL_CANCEL_BUTTON_LABEL} ">
<input title= "{$APP.LBL_FULL_FORM_BUTTON_TITLE}"
accessKey= "{$APP.LBL_FULL_FORM_BUTTON_KEY}"
class= "button"
type= "submit"
name= "button"
onclick= "this.form.to_pdf.value='0';this.form.action.value='EditView'; this.form.module.value='EcmPrices';"
value= " {$APP.LBL_FULL_FORM_BUTTON_LABEL} ">
</td>
<td align="right" nowrap>
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{$APP.NTC_REQUIRED}
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th align="left" class="dataLabel" colspan="4">
<h4 class="dataLabel"><slot>{$MOD.LBL_ECMPRICE_INFORMATION}</slot></h4>
</th>
</tr>
<tr>
<td valign="top" class="dataLabel" width="15%"><slot>{$MOD.LBL_NAME} <span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span></slot></td>
<td width="35%"><slot><textarea name='name' cols="40" tabindex='1' rows="1">{$NAME}</textarea></slot></td>
</tr>
</table>
</form>
<script>
{$additionalScripts}
</script>

View 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 ecmprices_ecmproducts as pp INNER JOIN ecmproducts AS p ON p.id=pp.ecmproduct_id INNER JOIN ecmprices as pr ON pp.ecmprice_id=pr.id WHERE pp.ecmprice_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 ecmprices_ecmproducts as pp INNER JOIN ecmproducts AS p ON p.id=pp.ecmproduct_id WHERE pp.ecmprice_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 ecmprices set currency_value='1' where id='".$_REQUEST['record']."'");
//echo "update ecmprices set currency_value='1' where id='".$_REQUEST['record']."'"; die();
}
$db->query("UPDATE ecmprices_ecmproducts SET price='".$price."' WHERE id='".$row['id']."'");
}
header("Location: index.php?module=EcmPrices&action=DetailView&record=".$_REQUEST['record']."&tab=items");

View File

@@ -0,0 +1,11 @@
<?php
$w=$GLOBALS['db']->query("select id,account_id from ecmprices where deleted='0'");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$ww=$GLOBALS['db']->query("select ecmproduct_id from ecmprices_ecmproducts where deleted='0' and ecmprice_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'");
}
}
}
?>

View 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']."'");
}
?>

View 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 ecmprices_ecmproducts set recipient_code='".$r['recipientcode']."' where ecmproduct_id='".$r['productid']."' and ecmprice_id='".$r['pricebookid']."'");
}
?>

View 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 ecmprices_ecmproducts set remarks_pl='".$r['remarks']."' where ecmproduct_id='".$r['ecmproduct_id']."'";
if($r['language']=="EN")print "update ecmprices_ecmproducts set remarks_en='".$r['remarks']."' where ecmproduct_id='".$r['ecmproduct_id']."'";
if($r['language']=="DE")print "update ecmprices_ecmproducts set remarks_de='".$r['remarks']."' where ecmproduct_id='".$r['ecmproduct_id']."'";
print "<br>";
}
?></textarea>

View 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['EcmPrice'] = array(
'table' => 'ecmprices',
'audited' => true,
'comment' => 'EcmPrices',
'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' => 'ecmprices_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' => 'ecmprices_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' => 'ecmprices_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' => 'ecmprices_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' =>'ecmpricesspk', 'type' =>'primary', 'fields'=>array('id')),
array('name' =>'idx_ecmprices_name', 'type' =>'index', 'fields'=>array('name'))
)
//RELATIONSHIPS SECTION
, 'relationships' => array (
'ecmprices_assigned_user' => array(
'lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id',
'rhs_module'=> 'EcmPrices', 'rhs_table'=> 'ecmprices', 'rhs_key' => 'assigned_user_id',
'relationship_type'=>'one-to-many')
,'ecmprices_modified_user' => array(
'lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id',
'rhs_module'=> 'EcmPrices', 'rhs_table'=> 'ecmprices', 'rhs_key' => 'modified_user_id',
'relationship_type'=>'one-to-many')
,'ecmprices_created_by' => array(
'lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id',
'rhs_module'=> 'EcmPrices', 'rhs_table'=> 'ecmprices', 'rhs_key' => 'created_by',
'relationship_type'=>'one-to-many')
),
//THIS FLAG ENABLES OPTIMISTIC LOCKING FOR SAVES FROM EDITVIEW
'optimistic_locking'=>true,
);
?>

View 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 EcmPricesViewList extends ViewList{
function EcmPricesViewList(){
parent::ViewList();
}
function display(){
if(!$this->bean->ACLAccess('list')){
ACLController::displayNoAccess();
return;
}
$this->module=$module = "EcmPrices";
$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();
}
}
}
?>