<?php
namespace AppBundle\EventListener;
use Pimcore\Event\Model\ElementEventInterface;
use Pimcore\Event\Model\DataObjectEvent;
use \Pimcore\Model\DataObject;
use \Pimcore\Model\DataObject\Attribute;
use \Pimcore\Model\DataObject\Brand;
use \Pimcore\Model\DataObject\Buyer;
use \Pimcore\Model\DataObject\Color;
use \Pimcore\Model\DataObject\ExtdClass;
use \Pimcore\Model\DataObject\Season;
use \Pimcore\Model\DataObject\Size;
use \Pimcore\Model\DataObject\SubBrand;
use \Pimcore\Model\DataObject\Vendor;
use \Pimcore\Model\DataObject\UnitOfMeasure;
use \Pimcore\Model\DataObject\TermCode;
use \Pimcore\Model\DataObject\PriceEvent;
use \Pimcore\Model\DataObject\ItemMaster;
use \Pimcore\Model\DataObject\MasterItemStatus;
use \Pimcore\Model\DataObject\SKUType;
use Pimcore\Db;
use Pimcore\Log\ApplicationLogger;
use Carbon\Carbon;
class ObjectBehaviourListener
{
public function onPostUpdate (ElementEventInterface $e)
{
}
public function onPreAdd(ElementEventInterface $e)
{
}
public function onPreUpdateOLD (ElementEventInterface $e)
{
}
public function onPreUpdate (ElementEventInterface $e)
{
if($e instanceof AssetEvent)
{
$foo = $e->getAsset();
}
else if ($e instanceof DocumentEvent)
{
$foo = $e->getDocument();
}
else if ($e instanceof DataObjectEvent)
{
$foo = $e->getObject();
$pid = $foo->getId();
// $foo->setInJDAProcess('no');
// $foo->save();
$claname = '';
$otype = $foo->geto_type();
if(($otype == 'object' || $otype == 'variant'))
{
$o_published =$foo->geto_published();
}
$user = \Pimcore\Tool\Admin::getCurrentUser();
// throw new \Pimcore\Model\Element\ValidationException($o_published, 1234);
if(($otype == 'object' || $otype == 'variant') && $o_published == 1 && $user != null)
{
$claname = $foo->geto_className();
}
if($claname == 'ItemMaster' || $claname == 'itemMaster' || $claname == 'TermCode' || $claname == 'termCode' || $claname == 'Vendor' || $claname == 'vendor' || $claname == 'MasterItemStatus' || $claname == 'masterItemStatus' || $claname == 'sKUType' || $claname == 'SKUType' || $claname == 'brand' || $claname == 'Brand' || $claname == 'SubBrand' || $claname == 'subBrand' || $claname == 'Buyer' || $claname == 'buyer' || $claname == 'Season' || $claname == 'season' || $claname == 'Color' || $claname == 'color' || $claname == 'Size' || $claname == 'size' || $claname == 'ExtdClass' || $claname == 'extdClass' || $claname == 'Attribute' || $claname == 'attribute' || $claname == 'UnitOfMeasure' || $claname == 'unitOfMeasure' || $claname == 'Hierarchy' || $claname == 'hierarchy' || $claname == 'BundleItem' || $claname == 'bundleItem' || $claname == 'priceEvent' || $claname == 'PriceEvent' )
{
$objectData = DataObject::getById($pid);
$tablename = "object_".$objectData->geto_classId();
$sql = "select * from ".$tablename." where o_id = '".$pid."' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$dataI =$stmt->fetchAll();
$updateJdaData=$dataI[0]['InJDAProcess'];
$className=$dataI[0]['oo_className'];
$dateTimeCreatedJDA = $foo->getdateTimeCreatedJDA();
//row new \Pimcore\Model\Element\ValidationException($className, 1234);
if($claname == 'ItemMaster' || $claname == 'itemMaster')
{
$statusCodedata = $dataI[0]['statusCode'];
$statusCodedata = $dataI[0]['statusCode'];
$stauscodesnew1 = explode(',',$statusCodedata);
$statusCode1 = $foo->getstatusCode();
$x=0;
$y=0;
while($x<count($stauscodesnew1))
{
if($stauscodesnew1 != '')
{
$stauscodesnew[$y] = $stauscodesnew1[$x];
$y++;
}
$x++;
}
if(in_array($statusCode1, $stauscodesnew))
{
}
else{
//throw new \Pimcore\Model\Element\ValidationException($statusCode1.'hi', 1234);
}
// print_r($stauscodesnew);
// $newd = implode('@',$stauscodesnew);
// throw new \Pimcore\Model\Element\ValidationException($stauscodesnew[0], 1234);
}
if($className == 'attribute' || $className == 'Attribute')
{
$attCodeNew = $foo->getattCode();
$attCode = $dataI[0]['attCode'];
if($dateTimeCreatedJDA != '')
{
if($attCode != $attCodeNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Attribute Code. ", 1234);
}
}
}
if($className == 'buyer' || $className == 'Buyer')
{
$buyerCDNew = $foo->getbuyerCD();
$buyerCD = $dataI[0]['buyerCD'];
if($dateTimeCreatedJDA != '')
{
if($buyerCD != $buyerCDNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Buyer Code. ", 1234);
}
}
}
if($className == 'brand' || $className == 'Brand')
{
$brandCDNew = $foo->getbrandCD();
$brandCD = $dataI[0]['brandCD'];
if($dateTimeCreatedJDA != '')
{
if($brandCD != $brandCDNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Brand Code. ", 1234);
}
}
}
if($className == 'color' || $className == 'Color')
{
$colorCDNew = $foo->getcolorCD();
$colorCD = $dataI[0]['colorCD'];
if($dateTimeCreatedJDA != '')
{
if($colorCD != $colorCDNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Color Code. ", 1234);
}
}
}
if($className == 'ExtdClass' || $className == 'extdClass')
{
$extdClassCDNew = $foo->getextdClassCD();
$extdClassCD = $dataI[0]['extdClassCD'];
if($dateTimeCreatedJDA != '')
{
if($extdClassCD != $extdClassCDNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Extended Classification Code. ", 1234);
}
}
}
if($className == 'MasterItemStatus' || $className == 'masterItemStatus')
{
$itemStatusNew = $foo->getitemStatus();
$itemStatus = $dataI[0]['itemStatus'];
if($dateTimeCreatedJDA != '')
{
if($itemStatus != $itemStatusNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Item Status. ", 1234);
}
}
}
if($className == 'Season' || $className == 'season')
{
$seasonCodeNew = $foo->getseasonCode();
$seasonCode = $dataI[0]['seasonCode'];
if($dateTimeCreatedJDA != '')
{
if($seasonCode != $seasonCodeNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Season Code. ", 1234);
}
}
}
if($className == 'Size' || $className == 'size')
{
$sizeCodeNew = $foo->getsizeCode();
$sizeCode = $dataI[0]['sizeCode'];
if($dateTimeCreatedJDA != '')
{
if($sizeCode != $sizeCodeNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Size Code. ", 1234);
}
}
}
if($className == 'SKUType' || $className == 'sKUType')
{
$SKUTypeNew = $foo->getSKUType();
$SKUType = $dataI[0]['SKUType'];
if($dateTimeCreatedJDA != '')
{
if($SKUType != $SKUTypeNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the SKU Type. ", 1234);
}
}
}
if($className == 'SubBrand' || $className == 'subBrand')
{
$subbrandCodeNew = $foo->getsubbrandCode();
$subbrandCode = $dataI[0]['subbrandCode'];
if($dateTimeCreatedJDA != '')
{
if($subbrandCode != $subbrandCodeNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Subbrand Code. ", 1234);
}
}
}
if($className == 'TermCode' || $className == 'termCode')
{
$paymentTermsCDNew = $foo->getpaymentTermsCD();
$paymentTermsCD = $dataI[0]['paymentTermsCD'];
if($dateTimeCreatedJDA != '')
{
if($paymentTermsCD != $paymentTermsCDNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Payment Terms Code. ", 1234);
}
}
}
if($className == 'unitOfMeasure' || $className == 'UnitOfMeasure')
{
$UMCDNew = $foo->getUMCD();
$UMCD = $dataI[0]['UMCD'];
if($dateTimeCreatedJDA != '')
{
if($UMCD != $UMCDNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the UM Code. ", 1234);
}
}
}
if($className == 'vendor' || $className == 'Vendor')
{
$vendorCodeNew = $foo->getvendorCode();
$vendorCode = $dataI[0]['vendorCode'];
if($dateTimeCreatedJDA != '')
{
if($vendorCode != $vendorCodeNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Vendor Code. ", 1234);
}
}
}
if($className == 'hierarchy' || $className == 'Hierarchy')
{
$deptCodeNew = $foo->getdeptCode();
$subdeptCodeNew = $foo->getsubdeptCode();
$clCodeNew = $foo->getclCode();
$subClassCodeNew = $foo->getsubClassCode();
$deptCode = $dataI[0]['deptCode'];
$subdeptCode = $dataI[0]['subdeptCode'];
$clCode = $dataI[0]['clCode'];
$subClassCode = $dataI[0]['subClassCode'];
if($dateTimeCreatedJDA != '')
{
if($deptCode != $deptCodeNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Department Code. ", 1234);
}
if($subdeptCode != $subdeptCodeNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Sub Department Code. ", 1234);
}
if($clCode != $clCodeNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Class Code. ", 1234);
}
if($subClassCode != $subClassCodeNew)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the Sub Class Code. ", 1234);
}
}
}
if($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException( "This object is currently in process JDA system.Please wait for few minutes. ", 1234);
}
}
// for item mater
if($claname == 'ItemMaster' || $claname == 'itemMaster' )
{
$upcNumber = $foo->getupcNumber();
$itemDesc =$foo->getitemDesc();
$styleNum =$foo->getstyleNum();
$mfrNum =$foo->getmfrNum();
$vendorPartNum =$foo->getvendorPartNum();
$innerPack =$foo->getinnerPack();
$casePack = $foo->getcasePack();
$dateTimeCreatedJDA = $foo->getdateTimeCreatedJDA();
if($foo->getSalesInformation())
{
if($foo->getSalesInformation()->getsaleInformation())
{
$cost = $foo->getsalesInformation()->getSaleInformation()->getcost();
$originalSalePrice = $foo->getsalesInformation()->getSaleInformation()->getoriginalSalePrice();
// else
// $cost= 0;
if(ctype_space($cost))
{
throw new \Pimcore\Model\Element\ValidationException("Please remove blank space from cost.", 1234);
}
if(ctype_space($originalSalePrice))
{
throw new \Pimcore\Model\Element\ValidationException("Please remove blank space from Original Sale Price.", 1234);
}
if(strpos($cost, ',') !== false){
throw new \Pimcore\Model\Element\ValidationException("Please remove commas from cost.", 1234);
}
if(strpos($originalSalePrice, ',') !== false){
throw new \Pimcore\Model\Element\ValidationException("Please remove commas from Original Sale Price.", 1234);
}
if(!is_numeric($cost)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter the valid cost.", 1234);
}
if(!is_numeric($originalSalePrice)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter the valid Original Sale Price.", 1234);
}
// // $cost= 0;
//
/* if (!preg_match("/^(?:100|\d{1,2})(?:\.\d{1,2})?$/",$cost)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter the valid cost.", 1234);
}
if (!preg_match("/^(?:100|\d{1,2})(?:\.\d{1,2})?$/",$originalSalePrice)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter the valid Original Sale Price.", 1234);
} */
if($cost <= 0)
{
throw new \Pimcore\Model\Element\ValidationException("Please enter the cost.", 1234);
}
if($originalSalePrice <= 0)
{
throw new \Pimcore\Model\Element\ValidationException("Please enter the originalSalePrice.", 1234);
}
if($dateTimeCreatedJDA)
{
$subqty11 = "select * from object_brick_query_SaleInformation_masterItem where o_id='".$pid."' and fieldname = 'salesInformation'";
$subqty12 = Db::get()->prepare($subqty11);
$subqty12->execute();
$subqty12data =$subqty12->fetchAll();
$originalSalePriceDB = $subqty12data[0]['originalSalePrice'];
// $myObject = DataObject::getById($pid);
// $originalSalePriceDB = $myObject->getsalesInformation()->getSaleInformation()->getoriginalSalePrice();
if($originalSalePriceDB > 0)
{
if($originalSalePriceDB != $originalSalePrice)
{
throw new \Pimcore\Model\Element\ValidationException("You are not authorised to update the originalSalePrice.", 1234);
}
}
}
}
else
{
throw new \Pimcore\Model\Element\ValidationException("Please enter the cost.", 1234);
}
}
else
{
throw new \Pimcore\Model\Element\ValidationException("Please enter the cost.", 1234);
}
if($upcNumber)
{
if(!is_numeric($upcNumber)) {
throw new \Pimcore\Model\Element\ValidationException("UPC number should be numeric.", 1234);
} else if(strlen($upcNumber) > 18) {
throw new \Pimcore\Model\Element\ValidationException("UPC number should not be more than 18 digits.", 1234);
} else {
/* Success */
}
}
if(strlen($itemDesc) > 30) {
throw new \Pimcore\Model\Element\ValidationException("Item Description should not be more than 30 characters.", 1234);
}
if(strlen($styleNum) > 15) {
throw new \Pimcore\Model\Element\ValidationException("Style number should not be more than 15 characters.", 1234);
}
if(strlen($mfrNum) > 15) {
throw new \Pimcore\Model\Element\ValidationException("Manufacturer number should not be more than 15 characters.", 1234);
}
if(strlen($vendorPartNum) > 15) {
throw new \Pimcore\Model\Element\ValidationException("Vendor Part number should not be more than 15 characters.", 1234);
}
if(empty($innerPack)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter inner pack.", 1234);
} else if(!is_numeric($innerPack)) {
throw new \Pimcore\Model\Element\ValidationException("Inner pack should be numeric.", 1234);
} else if(strlen($innerPack) > 9) {
throw new \Pimcore\Model\Element\ValidationException("Inner pack should not be more than 9 digits.", 1234);
} else {
/* Success */
}
if(empty($casePack)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter case pack.", 1234);
} else if(!is_numeric($casePack)) {
throw new \Pimcore\Model\Element\ValidationException("Case pack should be numeric.", 1234);
} else if(strlen($casePack) > 9) {
throw new \Pimcore\Model\Element\ValidationException("Case pack should not be more than 9 digits.", 1234);
} else {
/* Success */
}
$statusCodeDetails=$foo->getstatusCode();
$skuTypeDetails=$foo->getskuType();
$vendorDetails=$foo->getvendorDetails();
$brandDetails=$foo->getbrandDetails();
$subbrandDetails=$foo->getsubbrandDetails();
$buyerDetails=$foo->getbuyerDetails();
$seasonDetails=$foo->getseasonDetails();
$colorDetails=$foo->getcolorDetails();
$sizeDetails=$foo->getsizeDetails();
$hierarchyDetails=$foo->gethierarchyDetails();
$extdClassification=$foo->getextdClassification();
$attDetails1=$foo->getattDetails1();
$attDetails2=$foo->getattDetails2();
$attDetails3=$foo->getattDetails3();
$attDetails4=$foo->getattDetails4();
$attDetails5=$foo->getattDetails5();
$buyUMCDDetails=$foo->getbuyUMCD();
$sellUMCDDetails=$foo->getsellUMCD();
$totalStatusCodeDetails = count($statusCodeDetails);
$totalSkuTypeDetails = count($skuTypeDetails);
$totalVendorDetails = count($vendorDetails);
$totalBrandDetails = count($brandDetails);
$totalSubbrandDetails = count($subbrandDetails);
$totalSeasonDetails = count($seasonDetails);
$totalBuyerDetails = count($buyerDetails);
$totalColorDetails = count($colorDetails);
$totalSizeDetails = count($sizeDetails);
$totalHierarchyDetails = count($hierarchyDetails);
$totalextdClassification = count($extdClassification);
$totalattDetails1 = count($attDetails1);
$totalattDetails2 = count($attDetails2);
$totalattDetails3 = count($attDetails3);
$totalattDetails4 = count($attDetails4);
$totalattDetails5 = count($attDetails5);
$totalbuyUMCDDetails = count($buyUMCDDetails);
$totalsellUMCDDetails = count($sellUMCDDetails);
// if($totalattDetails1 < 1)
// {
// throw new \Pimcore\Model\Element\ValidationException("Please select Attribute Details 1.", 1234);
// }
// if($totalattDetails2 < 1)
// {
// throw new \Pimcore\Model\Element\ValidationException("Please select Attribute Details 2.", 1234);
// }
// if($totalattDetails3 < 1)
// {
// throw new \Pimcore\Model\Element\ValidationException("Please select Attribute Details 3.", 1234);
// }
// if($totalattDetails4 < 1)
// {
// throw new \Pimcore\Model\Element\ValidationException("Please select Attribute Details 4.", 1234);
// }
// if($totalattDetails5 < 1)
// {
// throw new \Pimcore\Model\Element\ValidationException("Please select Attribute Details 5.", 1234);
// }
if($totalHierarchyDetails < 1)
{
throw new \Pimcore\Model\Element\ValidationException("Please select Hierarchy Details.", 1234);
}
if($totalBuyerDetails < 1)
{
throw new \Pimcore\Model\Element\ValidationException("Please select buyer Details.", 1234);
}
if($totalBrandDetails < 1)
{
throw new \Pimcore\Model\Element\ValidationException("Please select brand Details.", 1234);
}
if($totalVendorDetails < 1)
{
throw new \Pimcore\Model\Element\ValidationException("Please select vendor Details.", 1234);
}
if($totalStatusCodeDetails < 1)
{
throw new \Pimcore\Model\Element\ValidationException("Please select status code Details.", 1234);
}
if($totalSkuTypeDetails < 1)
{
throw new \Pimcore\Model\Element\ValidationException("Please select sku type Details.", 1234);
}
if($totalVendorDetails < 1)
{
throw new \Pimcore\Model\Element\ValidationException("Please select vendor Details.", 1234);
}
if($totalbuyUMCDDetails < 1)
{
throw new \Pimcore\Model\Element\ValidationException("Please select Buy UM Code Details.", 1234);
}
if($totalsellUMCDDetails < 1)
{
throw new \Pimcore\Model\Element\ValidationException("Please select Sell UM Code Details.", 1234);
}
if($totalStatusCodeDetails > 0)
{
$i=1;
foreach ($statusCodeDetails as $statusCodeList)
{
$vId=$statusCodeList->getId();
$deleteReuest=$statusCodeList->getdeleteRequest();
$createdJdaDate=$statusCodeList->getdateTimeCreatedJDA();
$updateJdaData=$statusCodeList->getInJDAProcess();
$publishData=$statusCodeList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for status sku.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for status sku.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for status sku", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for status code details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalSkuTypeDetails > 0)
{
$i=1;
foreach ($skuTypeDetails as $skuTypeList)
{
$vId=$skuTypeList->getId();
$deleteReuest=$skuTypeList->getdeleteRequest();
$createdJdaDate=$skuTypeList->getdateTimeCreatedJDA();
$updateJdaData=$skuTypeList->getInJDAProcess();
$publishData=$skuTypeList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for sku type.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for sku type.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for sku type", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for sku type details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
// vendor details
if($totalVendorDetails > 0)
{
$i=1;
foreach ($vendorDetails as $vendorList)
{
$vId=$vendorList->getId();
$deleteReuest=$vendorList->getdeleteRequest();
$createdJdaDate=$vendorList->getdateTimeCreatedJDA();
$updateJdaData=$vendorList->getInJDAProcess();
$publishData=$vendorList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for vendor details.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for vendor details.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for vendor details.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for vendor details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalBrandDetails > 0)
{
$i=1;
foreach ($brandDetails as $brandList)
{
$brId=$brandList->getId();
$deleteReuest=$brandList->getdeleteRequest();
$createdJdaDate=$brandList->getdateTimeCreatedJDA();
$updateJdaData=$brandList->getInJDAProcess();
$publishData=$brandList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for brand details.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for brand details.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for brand details.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for brand details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalSubbrandDetails > 0)
{
$i=1;
foreach ($subbrandDetails as $subbrandList)
{
$subId=$subbrandList->getId();
$deleteReuest=$subbrandList->getdeleteRequest();
$createdJdaDate=$subbrandList->getdateTimeCreatedJDA();
$updateJdaData=$subbrandList->getInJDAProcess();
$publishData=$subbrandList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for subbrand details.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for subbrand details.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for subbrand details.", 1234);
}
elseif($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for subbrand details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalBuyerDetails > 0)
{
$i=1;
foreach ($buyerDetails as $buyerList)
{
$buId=$buyerList->getId();
$deleteReuest=$buyerList->getdeleteRequest();
$createdJdaDate=$buyerList->getdateTimeCreatedJDA();
$updateJdaData=$buyerList->getInJDAProcess();
$publishData=$buyerList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for buyer details.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for buyer details.", 1234);
}
else if($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for buyer details.", 1234);
}
elseif($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for buyer details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($buId);
}
}
if($totalSeasonDetails > 0)
{
$i=1;
foreach ($seasonDetails as $seaList)
{
$seaId=$seaList->getId();
$deleteReuest=$seaList->getdeleteRequest();
$createdJdaDate=$seaList->getdateTimeCreatedJDA();
$updateJdaData=$seaList->getInJDAProcess();
$publishData=$buyerList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for season details.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for season details.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for season details.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for season details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($buId);
}
}
if($totalColorDetails > 0)
{
$i=1;
foreach ($colorDetails as $colorList)
{
$colId=$colorList->getId();
$deleteReuest=$colorList->getdeleteRequest();
$createdJdaDate=$colorList->getdateTimeCreatedJDA();
$updateJdaData=$colorList->getInJDAProcess();
$publishData=$colorList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for color details.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for color details.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for color details.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for color details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalSizeDetails > 0)
{
$i=1;
foreach ($sizeDetails as $sizeList)
{
$siId=$sizeList->getId();
$deleteReuest=$sizeList->getdeleteRequest();
$createdJdaDate=$sizeList->getdateTimeCreatedJDA();
$updateJdaData=$sizeList->getInJDAProcess();
$publishData=$sizeList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for size details.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for size details.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for size details.", 1234);
}
elseif($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for size details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
//
if($totalextdClassification > 0)
{
$i=1;
foreach ($extdClassification as $List)
{
$extId=$List->getId();
$deleteReuest=$List->getdeleteRequest();
$createdJdaDate=$List->getdateTimeCreatedJDA();
$updateJdaData=$List->getInJDAProcess();
$publishData=$List->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for extened classification details.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for extened classification details.", 1234);
}
elseif($deleteReuest == true)
{
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for extened classification details.", 1234);
}
elseif($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for extened classification details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalattDetails1 > 0)
{
$i=1;
foreach ($attDetails1 as $attrOneList)
{
$att1Id=$attrOneList->getId();
$deleteReuest=$attrOneList->getdeleteRequest();
$createdJdaDate=$attrOneList->getdateTimeCreatedJDA();
$updateJdaData=$attrOneList->getInJDAProcess();
$attr1=$attrOneList->getattNum();
$publishData=$attrOneList->getPublished(true);
if($attr1 != 'IATRB1')
{
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 1 details.", 1234);
}
elseif($publishData == 0)
{
//validation msg for unpublished object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 1.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 1.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 1 details.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 1 details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalattDetails2 > 0)
{
$i=1;
foreach ($attDetails2 as $attTwoList)
{
$att2Id=$attTwoList->getId();
$deleteReuest=$attTwoList->getdeleteRequest();
$createdJdaDate=$attTwoList->getdateTimeCreatedJDA();
$updateJdaData=$attTwoList->getInJDAProcess();
$attr2=$attTwoList->getattNum();
$publishData=$attTwoList->getPublished(true);
if($attr2 != 'IATRB2')
{
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 2 details.", 1234);
}
elseif($publishData == 0)
{
//validation msg for unpublished object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 2.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 2.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 2 details.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 2 details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalattDetails3 > 0)
{
$i=1;
foreach ($attDetails3 as $attThreeList)
{
$att3Id=$attThreeList->getId();
$deleteReuest=$attThreeList->getdeleteRequest();
$createdJdaDate=$attThreeList->getdateTimeCreatedJDA();
$updateJdaData=$attThreeList->getInJDAProcess();
$attr3=$attThreeList->getattNum();
$publishData=$attThreeList->getPublished(true);
if($attr3 != 'IATRB3')
{
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 3 details.", 1234);
}
elseif($publishData == 0)
{
//validation msg for unpublished object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 3.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 3.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 3 details.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 3 details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalattDetails4 > 0)
{
$i=1;
foreach ($attDetails4 as $attFourList)
{
$att4Id=$attFourList->getId();
$deleteReuest=$attFourList->getdeleteRequest();
$createdJdaDate=$attFourList->getdateTimeCreatedJDA();
$updateJdaData=$attFourList->getInJDAProcess();
$attr4=$attFourList->getattNum();
$publishData=$attFourList->getPublished(true);
if($attr4 != 'IATRB4')
{
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 4 details.", 1234);
}
elseif($publishData == 0)
{
//validation msg for unpublished object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 4.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for sku type.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 4 details.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 4 details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalattDetails5 > 0)
{
$i=1;
foreach ($attDetails5 as $attFiveList)
{
$att5Id=$attFiveList->getId();
$deleteReuest=$attFiveList->getdeleteRequest();
$createdJdaDate=$attFiveList->getdateTimeCreatedJDA();
$updateJdaData=$attFiveList->getInJDAProcess();
$attr5=$attFiveList->getattNum();
$publishData=$attFiveList->getPublished(true);
if($attr5 != 'IATRB5')
{
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 5 details.", 1234);
}
elseif($publishData == 0)
{
//validation msg for unpublished object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 5.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 5.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 5 details.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for attribute 5 details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalbuyUMCDDetails > 0)
{
$i=1;
foreach ($buyUMCDDetails as $buyCodeList)
{
$att5Id=$buyCodeList->getId();
$deleteReuest=$buyCodeList->getdeleteRequest();
$createdJdaDate=$buyCodeList->getdateTimeCreatedJDA();
$updateJdaData=$buyCodeList->getInJDAProcess();
$publishData=$buyCodeList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for buy umcd details.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for buy umcd details.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for buy umcd details.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for buy umcd details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalsellUMCDDetails > 0)
{
$i=1;
foreach ($sellUMCDDetails as $sellCodeList)
{
$att5Id=$sellCodeList->getId();
$deleteReuest=$sellCodeList->getdeleteRequest();
$createdJdaDate=$sellCodeList->getdateTimeCreatedJDA();
$updateJdaData=$sellCodeList->getInJDAProcess();
$publishData=$sellCodeList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for sell umcd details.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for sell umcd details.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for sell umcd details.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for sell umcd details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
if($totalHierarchyDetails > 0)
{
$i=1;
foreach ($hierarchyDetails as $hierchyList)
{
$hieId=$hierchyList->getId();
$deleteReuest=$hierchyList->getdeleteRequest();
$createdJdaDate=$hierchyList->getdateTimeCreatedJDA();
$updateJdaData=$hierchyList->getInJDAProcess();
$subClassCode = $hierchyList->getsubClassCode();
$publishData=$hierchyList->getPublished(true);
if($subClassCode == '')
{
//validation msg for unpublished object
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for hierarchy details.", 1234);
}
if($publishData == 0)
{
//validation msg for unpublished object
//echo "yes";
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for hierarchy details.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for hierarchy details.", 1234);
}
elseif($deleteReuest == true)
{
//validation msg for delete request object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for hierarchy details.", 1234);
}
elseif($createdJdaDate == Null)
{
//validation msg for not creaed jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for hierarchy details.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
}
// for vendor class
if($claname == 'Vendor' || $claname == 'vendor' )
{
$vendorCode = $foo->getvendorCode();
$vendorName = $foo->getvendorName();
$addLine1 =$foo->getaddLine1();
$addLine2 =$foo->getaddLine2();
$addLine3 =$foo->getaddLine3();
$city = $foo->getcity();
$zipCD =$foo->getzipCD();
$phoneNum =$foo->getphoneNum();
$faxNum =$foo->getfaxNum();
$telNum = $foo->gettelNum();
$contactName =$foo->getcontactName();
$email = $foo->getemail();
$termsCode = $foo->gettermsCode();
$webAddress = $foo->getwebAddress();
$vc = is_int($vendorCode);
//throw new \Pimcore\Model\Element\ValidationException("Vendor code should be numeric 111.", 1234);
if(empty($vendorCode)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter vendor code.", 1234);
} else if (!filter_var($vendorCode, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Vendor code should be numeric.", 1234);
} else if(strlen($vendorCode) > 6) {
throw new \Pimcore\Model\Element\ValidationException("Vendor code should not be more than 6 digits.", 1234);
} else {
/* Success */
}
if(strlen($vendorName) > 35) {
throw new \Pimcore\Model\Element\ValidationException("Vendor name should not be more than 35 characters.", 1234);
}
if(strlen($addLine1) > 35) {
throw new \Pimcore\Model\Element\ValidationException("Address line 1 should not be more than 35 characters.", 1234);
}
if(strlen($addLine2) > 35) {
throw new \Pimcore\Model\Element\ValidationException("Address line 2 should not be more than 35 characters.", 1234);
}
if(strlen($addLine3) > 35) {
throw new \Pimcore\Model\Element\ValidationException("Address line 3 should not be more than 35 characters.", 1234);
}
if(strlen($city) > 20) {
throw new \Pimcore\Model\Element\ValidationException("City should not be more than 20 characters.", 1234);
}
if(strlen($zipCD) > 10) {
throw new \Pimcore\Model\Element\ValidationException("Zip code should not be more than 10 characters.", 1234);
}
if(strlen($phoneNum) > 18) {
throw new \Pimcore\Model\Element\ValidationException("Phione number should not be more than 18 characters.", 1234);
}
if(strlen($faxNum) > 18) {
throw new \Pimcore\Model\Element\ValidationException("Fax number should not be more than 18 characters.", 1234);
}
if(strlen($telNum) > 18) {
throw new \Pimcore\Model\Element\ValidationException("Telex number should not be more than 18 characters.", 1234);
}
if(strlen($contactName) > 20) {
throw new \Pimcore\Model\Element\ValidationException("Contact name should not be more than 20 characters.", 1234);
}
if(strlen($email) > 40) {
throw new \Pimcore\Model\Element\ValidationException("Email should not be more than 40 characters.", 1234);
}
if(strlen($webAddress) > 40) {
throw new \Pimcore\Model\Element\ValidationException("Web Address should not be more than 40 characters.", 1234);
}
if(count($termsCode) < 1)
{
throw new \Pimcore\Model\Element\ValidationException("Please select terms code.", 1234);
}
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'vendorDetails' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecord = count($data);
if($totalrecord > 0)
{
$venDelReq = $foo->getdeleteRequest();
if($venDelReq == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this vendor object.", 1234);
}
}
//get term code
$termDetails=$foo->gettermsCode();
$totaltermDetails = count($termDetails);
if($totaltermDetails > 0)
{
$i=1;
foreach ($termDetails as $termCodeList)
{
$vId=$termCodeList->getId();
$deleteReuest=$termCodeList->getdeleteRequest();
$createdJdaDate=$termCodeList->getdateTimeCreatedJDA();
$updateJdaData=$termCodeList->getInJDAProcess();
$publishData=$termCodeList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for term code.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for term code.", 1234);
}
if($deleteReuest == true)
{
//validation msg for deleteReuest object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for term code.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for term code.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
}
}
// for status code class
if($claname == 'MasterItemStatus' || $claname == 'MasterItemStatus' )
{
$itemStatus = $foo->getitemStatus();
$description = $foo->getdescription();
if(strlen($itemStatus) > 1) {
throw new \Pimcore\Model\Element\ValidationException("Item Status should not be more than 1 character.", 1234);
}
if(strlen($description) > 35) {
throw new \Pimcore\Model\Element\ValidationException("Description should not be more than 35 characters.", 1234);
}
$table = "object_relations_vendor";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'statusCode' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecord = count($data);
if($totalrecord > 0)
{
$termCodeDelete = $foo->getdeleteRequest();
if($termCodeDelete == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this object.", 1234);
}
}
}
// for SKUType class
if($claname == 'SKUType' || $claname == 'sKUType' )
{
$description = $foo->getdescription();
$SKUType = $foo->getSKUType();
if(strlen($SKUType) > 2) {
throw new \Pimcore\Model\Element\ValidationException("SKU Type should not be more than 2 characters.", 1234);
}
if(strlen($description) > 20) {
throw new \Pimcore\Model\Element\ValidationException("Description should not be more than 20 characters.", 1234);
}
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'skuType' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecord = count($data);
if($totalrecord > 0)
{
$venDelReq = $foo->getdeleteRequest();
if($venDelReq == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this skuType object.", 1234);
}
}
}
// for brand class
if($claname == 'brand' || $claname == 'Brand' )
{
$brandCD = $foo->getbrandCD();
$brandName = $foo->getbrandName();
if(empty($brandCD)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter brand code.", 1234);
} else if (!filter_var($brandCD, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Brand code should be numeric.", 1234);
} else if(strlen($brandCD) > 6) {
throw new \Pimcore\Model\Element\ValidationException("Brand should not be more than 6 digits.", 1234);
} else {
/* Success */
}
if(empty($brandName)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter brand name.", 1234);
}
else if(strlen($brandName) > 30) {
throw new \Pimcore\Model\Element\ValidationException("Brand name should not be more than 30 characters.", 1234);
}
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'brandDetails' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecord = count($data);
//extend check
$tableExt = "object_relations_exclassification";
$sqlExt = "select * from ".$tableExt." where dest_id='".$pid."' and fieldname= 'brandCode' ";
$stmtExt = Db::get()->prepare($sqlExt);
$stmtExt->execute();
$dataExt =$stmtExt->fetchAll();
$totalrecordExt = count($dataExt);
if($totalrecord > 0 || $totalrecordExt > 0)
{
$venDelReq = $foo->getdeleteRequest();
if($venDelReq == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this object.", 1234);
}
}
}
// for sunbrand class
if($claname == 'SubBrand' || $claname == 'subBrand' )
{
$subbrandCode = $foo->getsubbrandCode();
$subbrandName = $foo->getsubbrandName();
if(empty($subbrandCode)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter sub brand code.", 1234);
} else if (!filter_var($subbrandCode, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Sub brand code should be numeric.", 1234);
} else if(strlen($subbrandCode) > 5) {
throw new \Pimcore\Model\Element\ValidationException("Sub brand code should not be more than 5 digits.", 1234);
} else {
/* Success */
}
if(strlen($subbrandName) > 35) {
throw new \Pimcore\Model\Element\ValidationException("Sub brand name should not be more than 35 digits.", 1234);
}
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'subbrandDetails' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecord = count($data);
if($totalrecord > 0)
{
$venDelReq = $foo->getdeleteRequest();
if($venDelReq == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this object.", 1234);
}
}
}
// for buyer class
if($claname == 'Buyer' || $claname == 'buyer' )
{
$buyerCD = $foo->getbuyerCD();
$buyerName = $foo->getbuyerName();
$telexNum = $foo->gettelexNum();
$email = $foo->getemail();
if(empty($buyerCD)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter buyer code.", 1234);
}
else if(strlen($buyerCD) > 3) {
throw new \Pimcore\Model\Element\ValidationException("Buyer code should not be more than 3 characters.", 1234);
} else {
/* Success */
}
if(empty($buyerName)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter buyer name.", 1234);
}
else if(strlen($buyerName) > 20) {
throw new \Pimcore\Model\Element\ValidationException("Buyer name should not be more than 20 characters.", 1234);
} else {
/* Success */
}
if(strlen($email) > 40) {
throw new \Pimcore\Model\Element\ValidationException("Email address should not be more than 40 characters.", 1234);
} else {
/* Success */
}
if(strlen($telexNum) > 4) {
throw new \Pimcore\Model\Element\ValidationException("Telephone Extension Number should not be more than 4 characters.", 1234);
} else {
/* Success */
}
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'buyerDetails' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecord = count($data);
if($totalrecord > 0)
{
$venDelReq = $foo->getdeleteRequest();
if($venDelReq == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this object.", 1234);
}
}
}
// for season class
if($claname == 'season' || $claname == 'Season' )
{
$seasonCode = $foo->getseasonCode();
$description = $foo->getdescription();
if(strlen($seasonCode) > 3) {
throw new \Pimcore\Model\Element\ValidationException("Season code should not be more than 3 characters.", 1234);
}
if(strlen($description) > 25) {
throw new \Pimcore\Model\Element\ValidationException("Description should not be more than 25 characters.", 1234);
}
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'seasonDetails' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecord = count($data);
if($totalrecord > 0)
{
$venDelReq = $foo->getdeleteRequest();
if($venDelReq == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this season object.", 1234);
}
}
}
// for color class
if($claname == 'color' || $claname == 'Color' )
{
$colorCD = $foo->getcolorCD();
$desc = $foo->getdesc();
$shortDesc = $foo->getshortDesc();
if(empty($colorCD)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter color code.", 1234);
} else if (!filter_var($colorCD, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Color code should be numeric.", 1234);
} else if(strlen($colorCD) > 4) {
throw new \Pimcore\Model\Element\ValidationException("Color code should not be more than 4 digits.", 1234);
} else {
/* Success */
}
if(strlen($desc) > 25) {
throw new \Pimcore\Model\Element\ValidationException("Short description should not be more than 25 characters.", 1234);
}
if(strlen($shortDesc) > 5) {
throw new \Pimcore\Model\Element\ValidationException("Short description should not be more than 5 characters.", 1234);
}
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'colorDetails' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecord = count($data);
if($totalrecord > 0)
{
$venDelReq = $foo->getdeleteRequest();
if($venDelReq == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this color object.", 1234);
}
}
}
// for size class
if($claname == 'size' || $claname == 'Size' )
{
$sizeCode = $foo->getsizeCode();
$description = $foo->getdescription();
$shortDesc = $foo->getshortDesc();
if(strlen($sizeCode) > 4) {
throw new \Pimcore\Model\Element\ValidationException("Size code should not be more than 4 characters.", 1234);
}
if(strlen($description) > 25) {
throw new \Pimcore\Model\Element\ValidationException("Description should not be more than 25 characters.", 1234);
}
if(strlen($shortDesc) > 5) {
throw new \Pimcore\Model\Element\ValidationException("Short description should not be more than 5 characters.", 1234);
}
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'sizeDetails' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecord = count($data);
if($totalrecord > 0)
{
$venDelReq = $foo->getdeleteRequest();
if($venDelReq == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this size object.", 1234);
}
}
}
// for ExtdClass class
if($claname == 'ExtdClass' || $claname == 'extdClass' )
{
$brandCodeDetails=$foo->getbrandCode();
$id=$foo->getId();
$extdClassCD = $foo->getextdClassCD();
$brandCode = $foo->getbrandCode();
$extdClassName = $foo->getextdClassName();
if(empty($extdClassCD)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter Extended Classification Code.", 1234);
} else if (!filter_var($extdClassCD, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Extended Classification Code should be numeric.", 1234);
} else if(strlen($extdClassCD) > 3) {
throw new \Pimcore\Model\Element\ValidationException("Extended Classification Code should not be more than 3 digits.", 1234);
} else {
/* Success */
}
if(strlen($extdClassName) > 25) {
throw new \Pimcore\Model\Element\ValidationException("Extended Classification Name should not be more than 25 characters.", 1234);
}
if(count($brandCode) < 1)
{
throw new \Pimcore\Model\Element\ValidationException("Please select brand code.", 1234);
}
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'extdClassification' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecord = count($data);
if($totalrecord > 0)
{
$venDelReq = $foo->getdeleteRequest();
if($venDelReq == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this extended classification object.", 1234);
}
}
// brand code check
$brandCodeDetails=$foo->getbrandCode();
$totalbrandCodeDetails = count($brandCodeDetails);
if($totalbrandCodeDetails > 0)
{
$i=1;
foreach ($brandCodeDetails as $brandCodeList)
{
$vId=$brandCodeList->getId();
$deleteReuest=$brandCodeList->getdeleteRequest();
$createdJdaDate=$brandCodeList->getdateTimeCreatedJDA();
$updateJdaData=$brandCodeList->getInJDAProcess();
$publishData=$brandCodeList->getPublished(true);
if($publishData == 0)
{
//validation msg for unpublished object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for brand code.", 1234);
}
elseif($updateJdaData == "yes")
{
//validation msg for object in update procedure so object not able to add
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for brand code.", 1234);
}
if($deleteReuest == true)
{
//validation msg for deleteReuest object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for brand code.", 1234);
}
elseif ($createdJdaDate == Null)
{
//validation msg for not created jda object
throw new \Pimcore\Model\Element\ValidationException("Please select valid records for brand code.", 1234);
}
$i++;
//$myObject = DataObject\Myclassname::getById($vId);
}
//$c $vId
// $peObject = new DataObject\ExtdClass\Listing();
// $peObject->setCondition("extdClassCD = ? and o_id != :id", [$extdClassCD,$id]);
// $peObject->load();
// $peId = array();
// foreach ($peObject as $entry) {
// $ecId = $entry->getId();
// $ecobjectData = DataObject::getById($ecId);
// $ecbrandCodeDetails=$ecobjectData->getbrandCode();
// $totalecbrandCodeDetails = count($ecbrandCodeDetails);
// if($totalecbrandCodeDetails > 0)
// {
// $i=1;
// foreach ($ecbrandCodeDetails as $brandCodeList)
// {
// $ecvId=$brandCodeList->getId();
// if($vId == $ecvId)
// {
// throw new \Pimcore\Model\Element\ValidationException("Extended Classification Code is already exists for Brand 'X'.", 1234);
// }
// }
// }
// }
}
}
// for attibute class
if($claname == 'Attribute' || $claname == 'attribute' )
{
$attCode = $foo->getattCode();
$description = $foo->getdescription();
if(empty($attCode)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter attribute code.", 1234);
}
else if(strlen($attCode) > 2) {
throw new \Pimcore\Model\Element\ValidationException("Attribute code should not be more than 2 characters.", 1234);
}
if(strlen($description) > 35) {
throw new \Pimcore\Model\Element\ValidationException("Attribute description should not be more than 35 characters.", 1234);
}
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and ( fieldname= 'attDetails1' or fieldname= 'attDetails2' or fieldname= 'attDetails3' or fieldname = 'attDetails4' or fieldname= 'attDetails5' ) ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalAtt1 = count($data);
if($totalAtt1 > 0)
{
$venDelReq = $foo->getdeleteRequest();
if($venDelReq == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this attibute object.", 1234);
}
}
}
// for UnitOfMeasure class
if($claname == 'UnitOfMeasure' || $claname == 'UnitOfMeasure' )
{
$numSellUnitsBuy = $foo->getnumSellUnitsBuy();
$description =$foo->getdescription();
$UMCD = $foo->getUMCD();
if(empty($numSellUnitsBuy)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter Number Sell Units Buy.", 1234);
} else if (!filter_var($numSellUnitsBuy, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Number Sell Units Buy should be numeric.", 1234);
} else if(strlen($numSellUnitsBuy) > 4) {
throw new \Pimcore\Model\Element\ValidationException("Number Sell Units Buy should not be more than 4 digits.", 1234);
} else {
/* Success */
}
if(strlen($UMCD) > 3) {
throw new \Pimcore\Model\Element\ValidationException("UM Code should not be more than 3 characters.", 1234);
}
if(strlen($description) > 20) {
throw new \Pimcore\Model\Element\ValidationException("Description should not be more than 20 characters.", 1234);
}
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'buyUMCD' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecord = count($data);
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'sellUMCD' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecordSell = count($data);
if($totalrecord > 0 || $totalrecordSell > 0)
{
$venDelReq = $foo->getdeleteRequest();
if($venDelReq == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this object.", 1234);
}
}
}
if($claname == 'BundleItem' || $claname == 'bundleItem' )
{
$ComponentQty = $foo->getComponentQty();
$ParentSKU = $foo->getParentSKU();
$ChildSKUs = $foo->getChildSKUs();
if(empty($ParentSKU)) {
throw new \Pimcore\Model\Element\ValidationException("Please select parent SKU.", 1234);
}
if(empty($ChildSKUs)) {
throw new \Pimcore\Model\Element\ValidationException("Please select child SKU.", 1234);
}
if(empty($ComponentQty)) {
throw new \Pimcore\Model\Element\ValidationException("Please enter Component Quantity.", 1234);
} else if (!filter_var($ComponentQty, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Component Quantity should be numeric.", 1234);
} else if(strlen($ComponentQty) > 9) {
throw new \Pimcore\Model\Element\ValidationException("Component Quantity should not be more than 9 digits.", 1234);
} else {
/* Success */
}
}
if($claname == 'priceEvent' || $claname == 'PriceEvent' )
{
$eventDesc = $foo->geteventDesc();
$CurrentPrice =$foo->getCurrentPrice();
$eventSeason = $foo->geteventSeason();
$priceLevel = $foo->getpriceLevel();
$store = $foo->getstore();
$itemMasterSKU = $foo->getitemMasterSKU();
$changeByPercentValue = $foo->getchangeByPercentValue();
$changeByValue = $foo->getchangeByValue();
//throw new \Pimcore\Model\Element\ValidationException(($CurrentPrice)." - ".$priceLevel." - ".$store."", 1234);
if($changeByValue)
{
if($changeByPercentValue == 'changeByPercentValue')
{
if(!is_numeric($changeByValue)) {
throw new \Pimcore\Model\Element\ValidationException("Change by percent should be numeric.", 1234);
} else if(strlen($changeByValue) > 12) {
throw new \Pimcore\Model\Element\ValidationException("Change by percent should not be more than 12 digits.", 1234);
} else {
/* Success */
}
}
if($changeByPercentValue == 'changeByPrice')
{
// if (!filter_var($changeByValue, FILTER_VALIDATE_INT)){
if(!is_numeric($changeByValue)) {
throw new \Pimcore\Model\Element\ValidationException("Change by price should be numeric.", 1234);
} else if(strlen($changeByValue) > 12) {
throw new \Pimcore\Model\Element\ValidationException("Change by price should not be more than 12 digits.", 1234);
} else {
/* Success */
}
}
}
if(strlen($eventDesc) > 30) {
throw new \Pimcore\Model\Element\ValidationException("Description should not be more than 30 characters.", 1234);
}
if(empty($eventSeason)) {
throw new \Pimcore\Model\Element\ValidationException("Please select event season.", 1234);
}
if(empty($priceLevel)) {
throw new \Pimcore\Model\Element\ValidationException("Please select price level.", 1234);
}
if(empty($store) && $store != 0) {
throw new \Pimcore\Model\Element\ValidationException("Please select store.", 1234);
}
if(empty($itemMasterSKU)) {
throw new \Pimcore\Model\Element\ValidationException("Please select SKU.", 1234);
}
}
if($claname == 'TermCode' || $claname == 'termCode' )
{
$paymentTermsCD = $foo->getpaymentTermsCD();
$daysToDueDate = $foo->getdaysToDueDate();
$daysToDiscDate = $foo->getdaysToDiscDate();
if($paymentTermsCD)
{
if (!filter_var($paymentTermsCD, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Payment terms code should be numeric.", 1234);
} else if(strlen($paymentTermsCD) > 3) {
throw new \Pimcore\Model\Element\ValidationException("Payment terms code should not be more than 3 digits.", 1234);
} else {
/* Success */
}
}
if($daysToDueDate)
{
if (!filter_var($daysToDueDate, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Days to due date should be numeric.", 1234);
} else if(strlen($daysToDueDate) > 4) {
throw new \Pimcore\Model\Element\ValidationException("Days to due date should not be more than 4 digits.", 1234);
} else {
/* Success */
}
}
if($daysToDiscDate)
{
if (!filter_var($daysToDiscDate, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Days to discount date should be numeric.", 1234);
} else if(strlen($daysToDiscDate) > 4) {
throw new \Pimcore\Model\Element\ValidationException("Days to discount date should not be more than 4 digits.", 1234);
} else {
/* Success */
}
}
}
// for heirarchy class
if($claname == 'hierarchy' || $claname == 'Hierarchy' )
{
$deptCode = $foo->getdeptCode();
$subdeptCode = $foo->getsubdeptCode();
$clCode = $foo->getclCode();
$subClassCode = $foo->getsubClassCode();
$deptName = $foo->getdeptName();
$subdeptName = $foo->getsubdeptName();
$clName = $foo->getclName();
$subClassName = $foo->getsubClassName();
$deptShortName = $foo->getdeptShortName();
$subdeptShortName = $foo->getsubdeptShortName();
$clShortName = $foo->getclShortName();
$subClassShortName = $foo->getsubClassShortName();
// if(empty($deptCode)) {
// throw new \Pimcore\Model\Element\ValidationException("Please enter department code.", 1234);
// } else
if (!filter_var($deptCode, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Department code should be numeric.", 1234);
} else
if(strlen($deptCode) > 3) {
throw new \Pimcore\Model\Element\ValidationException("Department code should not be more than 3 digits.", 1234);
} else {
/* Success */
}
// if(empty($subdeptCode)) {
// throw new \Pimcore\Model\Element\ValidationException("Please enter sub department code.", 1234);
// } else
if($subdeptCode)
{
if (!filter_var($subdeptCode, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Sub department code should be numeric.", 1234);
}
else if(strlen($subdeptCode) > 3) {
throw new \Pimcore\Model\Element\ValidationException("Sub department code should not be more than 3 digits.", 1234);
} else {
/* Success */
}
}
// if(empty($clCode)) {
// throw new \Pimcore\Model\Element\ValidationException("Please enter class code.", 1234);
// } else
if($clCode)
{
if (!filter_var($clCode, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Classification code should be numeric.", 1234);
} else if(strlen($clCode) > 3) {
throw new \Pimcore\Model\Element\ValidationException("Classification code should not be more than 3 digits.", 1234);
} else {
/* Success */
}
}
// if(empty($subClassCode)) {
// throw new \Pimcore\Model\Element\ValidationException("Please enter sub class code.", 1234);
// } else
if($subClassCode)
{
if (!filter_var($subClassCode, FILTER_VALIDATE_INT)){
throw new \Pimcore\Model\Element\ValidationException("Sub class code should be numeric.", 1234);
} else if(strlen($subClassCode) > 3) {
throw new \Pimcore\Model\Element\ValidationException("Sub class code should not be more than 3 digits.", 1234);
} else {
/* Success */
}
}
if(strlen($deptName) > 25) {
throw new \Pimcore\Model\Element\ValidationException("Department name should not be more than 25 characters.", 1234);
}
if(strlen($subdeptName) > 25) {
throw new \Pimcore\Model\Element\ValidationException("Sub department name should not be more than 25 characters.", 1234);
}
if(strlen($clName) > 25) {
throw new \Pimcore\Model\Element\ValidationException("Classification name should not be more than 25 characters.", 1234);
}
if(strlen($subClassName) > 25) {
throw new \Pimcore\Model\Element\ValidationException("Sub class name should not be more than 25 characters.", 1234);
}
if(strlen($deptShortName) > 8) {
throw new \Pimcore\Model\Element\ValidationException("Department short name should not be more than 8 characters.", 1234);
}
if(strlen($subdeptShortName) > 8) {
throw new \Pimcore\Model\Element\ValidationException("Sub department short name should not be more than 8 characters.", 1234);
}
if(strlen($clShortName) > 8) {
throw new \Pimcore\Model\Element\ValidationException("Classification short name should not be more than 8 characters.", 1234);
}
if(strlen($subClassShortName) > 8) {
throw new \Pimcore\Model\Element\ValidationException("Sub class short name should not be more than 8 characters.", 1234);
}
$table = "object_relations_masterItem";
$sql = "select * from ".$table." where dest_id='".$pid."' and fieldname= 'hierarchyDetails' ";
$stmt = Db::get()->prepare($sql);
$stmt->execute();
$data =$stmt->fetchAll();
$totalrecord = count($data);
if($totalrecord > 0)
{
$venDelReq = $foo->getdeleteRequest();
if($venDelReq == true)
{
throw new \Pimcore\Model\Element\ValidationException("Not perform delete operation for this heirarchy object.", 1234);
}
}
}
}
}
}