I have a script (below) which connects to a vCenter and pulls off all of the VMs and what host they are currently on. The only thing is it only gives me the host ID not the name. Is there any way to get the name as well or lookup the name after it has got the id?
<?php
class soapclientd extends soapclient
{
public $action = false;
public function __construct($wsdl, $options = array())
{
parent::__construct($wsdl, $options);
}
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
$resp = parent::__doRequest($request, $location, $action, $version, $one_way);
return $resp;
}
}
$client = new SoapClient("https://192.168.1.103/sdk/vimService.wsdl", array("trace" => 1, "location"=>"https://192.168.1.103/sdk"));
try
{
$request = new stdClass();
$request->_this = array ('_' => 'ServiceInstance', 'type' => 'ServiceInstance');
$response = $client->__soapCall('RetrieveServiceContent', array((array)$request));
}
catch (Exception $e)
{
echo $e->getMessage();
exit;
}
$ret = $response->returnval;
try
{
$request = new stdClass();
$request->_this = $ret->sessionManager;
$request->userName = 'root';
$request->password = 'vmware';
$response = $client->__soapCall('Login', array((array)$request));
}
catch (Exception $e)
{
echo $e->getMessage();
exit;
}
$ss1 = new soapvar(array ('name' => 'FolderTraversalSpec'), SOAP_ENC_OBJECT, null, null, 'selectSet', null);
$ss2 = new soapvar(array ('name' => 'DataCenterVMTraversalSpec'), SOAP_ENC_OBJECT, null, null, 'selectSet', null);
$a = array ('name' => 'FolderTraversalSpec', 'type' => 'Folder', 'path' => 'childEntity', 'skip' => false, $ss1, $ss2);
$ss = new soapvar(array ('name' => 'FolderTraversalSpec'), SOAP_ENC_OBJECT, null, null, 'selectSet', null);
$b = array ('name' => 'DataCenterVMTraversalSpec', 'type' => 'Datacenter', 'path' => 'vmFolder', 'skip' => false, $ss);
$res = null;
try
{
$request = new stdClass();
$request->_this = $ret->propertyCollector;
$request->specSet = array (
'propSet' => array (
array ('type' => 'VirtualMachine', 'all' => 0, 'pathSet' => array ('name','runtime.powerState', 'config.hardware.numCPU', 'config.hardware.memoryMB', 'runtime.host')),
),
'objectSet' => array (
'obj' => $ret->rootFolder,
'skip' => false,
'selectSet' => array (
new soapvar($a, SOAP_ENC_OBJECT, 'TraversalSpec'),
new soapvar($b, SOAP_ENC_OBJECT, 'TraversalSpec'),
),
)
);
$res = $client->__soapCall('RetrieveProperties', array((array)$request));
}
catch (Exception $e)
{
echo $e->getMessage();
}
$tvCPU = 0;
$tvRAM = 0;
echo "<table><tr><td width='450px'>Name</td> <td width='100px'>vRAM (MB)</td><td width='100px'>vCPU</td><td width='100px'>Power State</td><td width='100px'>Host</td> </tr>";
$arrlength=count($res ->returnval);
for($x=0;$x<$arrlength;$x++)
{
$name = $res -> returnval[$x] -> propSet[2]->val;
$vRam = $res -> returnval[$x] -> propSet[0]->val;
$vCPU = $res -> returnval[$x] -> propSet[1]->val;
$pState = $res -> returnval[$x] -> propSet[4]->val;
$host = $res -> returnval[$x] -> propSet[3]->val->_;
echo "<tr><td width='450px'>".$name.
"</td><td>".$vRam.
"</td><td>".$vCPU.
"</td> <td>".$pState.
"</td> <td>".$host.
"</td></tr>";
$tvCPU = $tvCPU + $vCPU;
$tvRAM = $tvRAM + $vRam;
}
echo "<tr><td width='450px'>Total VMs - ".$x."</td><td>". $tvRAM."</td><td>". $tvCPU."</td></tr>";
?>
Related
I'm trying to get the response of A SOAP Service, but I can't get the subcollections data.
When I call the ws method using a soap client software I get the next response:
<WSGLMSuit.METHODNAME xmlns="http://tempuri.org/">
<Sdtpolizadetalle>
<Empresa>1</Empresa>
<DscEmpresa>TEST</DscEmpresa>
<Rama>22</Rama>
<DscRama>COMBINADO FAMILIAR</DscRama>
<Poliza>000000</Poliza>
<DscRiesgo/>
<InicioVigencia>2019-03-18</InicioVigencia>
<FinVigencia>2019-09-18</FinVigencia>
<Productor>3311</Productor>
<NombreProductor>TEST</NombreProductor>
<Tomador>
<CodTomador>336028</CodTomador>
<NombreTomador>TEST</NombreTomador>
<Domicilio>SAAVEDRA 1174 Dpto. 0</Domicilio>
<Localidad>TRES ARROYOS</Localidad>
<CodigoPostal>7500</CodigoPostal>
</Tomador>
<DscMoneda>PESOS</DscMoneda>
<CantidadCuotas>3</CantidadCuotas>
<Suplementos>
<Suplemento>
<Suplemento>0</Suplemento>
<TipoOperacion>02</TipoOperacion>
<SubTipoOperacion>000</SubTipoOperacion>
<DscOperacion>GENERAL</DscOperacion>
<InicioVigencia>2019-03-18</InicioVigencia>
<FinVigencia>2019-09-18</FinVigencia>
<Prima>2515.95</Prima>
<Premio>3104.68</Premio>
<Cuotas>
<Cuota>
<NroCuota>1</NroCuota>
<Vencimiento>2019-03-18</Vencimiento>
<Estado>Pagada</Estado>
<Importe>519.68</Importe>
<NroCupon>1</NroCupon>
</Cuota>
<Cuota>
<NroCuota>2</NroCuota>
<Vencimiento>2019-04-18</Vencimiento>
<Estado>Vencida</Estado>
<Importe>517.00</Importe>
<NroCupon>2</NroCupon>
</Cuota>
<Cuota>
<NroCuota>3</NroCuota>
<Vencimiento>2019-05-18</Vencimiento>
<Estado>Impaga</Estado>
<Importe>517.00</Importe>
<NroCupon>3</NroCupon>
</Cuota>
</Cuotas>
</Suplemento>
</Suplementos>
</Sdtpolizadetalle>
<Sesionexpirada>false</Sesionexpirada>
</WSGLMSuit.METHODNAMEResponse>
So, I made a function in PHP with SoapClient class to make same request and get the result parsed as JSON but it doesn't giving me the "Suplementos" collection and its data.
{
"Sdtpolizadetalle": {
"Empresa": 1,
"DscEmpresa": "TEST",
"Rama": 22,
"DscRama": "COMBINADO FAMILIAR",
"Poliza": 129031,
"DscRiesgo": "",
"InicioVigencia": "2019-03-18",
"FinVigencia": "2019-09-18",
"Productor": 3311,
"NombreProductor": "TEST",
"Tomador": {
"CodTomador": 336028,
"NombreTomador": "TEST",
"Domicilio": "SAAVEDRA 1174 Dpto. 0",
"Localidad": "TRES ARROYOS",
"CodigoPostal": "7500"
},
"DscMoneda": "PESOS",
"CantidadCuotas": 3,
"Suplementos": {} // <--- HERE IS THE ISSUE
},
"Sesionexpirada": false
}
The PHP function is:
$wsdl = "http://wsdlservice.org?wsdl";
$params = $request->getParsedBody();
$options = array(
'soap_version' => SOAP_1_2,
'style' => SOAP_DOCUMENT,
'use' => SOAP_LITERAL,
'exceptions' => true,
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE,
'encoding' => 'UTF-8'
);
$soap = new SoapClient($wsdl, $options);
$clientRes = $soap->METHODNAME($params);
return json_encode($clientRes, JSON_PRETTY_PRINT);
Finally I got a solution. I found a function for parsing XML string to Array. So what I do is get the response as XML, save it into a file and parse it with that function. Code better than words:
function xmlToArray($xml, $options = array())
{
$defaults = array(
'namespaceSeparator' => ':',
'attributePrefix' => '#',
'alwaysArray' => array(),
'autoArray' => true,
'textContent' => '$',
'autoText' => true,
'keySearch' => false,
'keyReplace' => false
);
$options = array_merge($defaults, $options);
$namespaces = $xml->getDocNamespaces();
$namespaces[''] = null;
$attributesArray = array();
foreach ($namespaces as $prefix => $namespace) {
foreach ($xml->attributes($namespace) as $attributeName => $attribute) {
if ($options['keySearch']) $attributeName =
str_replace($options['keySearch'], $options['keyReplace'], $attributeName);
$attributeKey = $options['attributePrefix']
. ($prefix ? $prefix . $options['namespaceSeparator'] : '')
. $attributeName;
$attributesArray[$attributeKey] = (string)$attribute;
}
}
$tagsArray = array();
foreach ($namespaces as $prefix => $namespace) {
foreach ($xml->children($namespace) as $childXml) {
$childArray = xmlToArray($childXml, $options);
list($childTagName, $childProperties) = each($childArray);
if ($options['keySearch'])
$childTagName = str_replace($options['keySearch'], $options['keyReplace'], $childTagName);
if ($prefix)
$childTagName = $prefix . $options['namespaceSeparator'] . $childTagName;
if (!isset($tagsArray[$childTagName])) {
$tagsArray[$childTagName] =
in_array($childTagName, $options['alwaysArray']) || !$options['autoArray']
? array($childProperties)
: $childProperties;
} elseif (
is_array($tagsArray[$childTagName]) && array_keys($tagsArray[$childTagName])
=== range(0, count($tagsArray[$childTagName]) - 1)
) {
$tagsArray[$childTagName][] = $childProperties;
} else {
$tagsArray[$childTagName] = array($tagsArray[$childTagName], $childProperties);
}
}
}
$textContentArray = array();
$plainText = trim((string)$xml);
if ($plainText !== '') $textContentArray[$options['textContent']] = $plainText;
$propertiesArray = !$options['autoText'] || $attributesArray || $tagsArray || ($plainText === '')
? array_merge($attributesArray, $tagsArray, $textContentArray) : $plainText;
return array(
$xml->getName() => $propertiesArray
);
}
$params = array('key' => 'value') // params needed to make the request
$options = array(
'trace' => 1,
'exceptions' => true
);
try {
$soap = new SoapClient($url, $options);
$soap->method($params); // replace method name
$xmlResponse = $soap->__getLastResponse();
} catch (Exception $e) {
die(
json_encode(
[
'error' => 'Cannot request to WS. ' . $e->getMessage()
]
)
);
// save the response into an xml file for parse
// it and return its content as json
if (file_put_contents('response.xml', $xmlResponse)) {
$xmlNode = simplexml_load_file($this->tempPath);
$arrayData = xmlToArray($xmlNode);
unlink('response.xml');
return json_encode($arrayData, JSON_PRETTY_PRINT);
} else {
return json_encode(['error' => 'Error saving the response into file.']);
}
I saw the similar questions, but it has not helped me. I am trying to fetch message. I need full message with all parts, headers, attachments.
$fetchQuery = new Horde_Imap_Client_Fetch_Query();
$fetchQuery->fullText();
/** #var Horde_Imap_Client_Fetch_Results $mail */
$results = $client->fetch('INBOX', $fetchQuery, ['ids' => new Horde_Imap_Client_Ids(11632)]);
var_dump($results->first()->getEnvelope()->subject);
I tried a lot of variants. But I can't get any info about message. The subject is empty string. I am sure, such mail with that uid exists, I got this uid with Horde also.
Try the code mentioned below. $results array has all the items you need.
$uids = new \Horde_Imap_Client_Ids($thread_uids);
$query = new \Horde_Imap_Client_Fetch_Query();
$query->envelope();
$query->structure();
$messages = $oClient->fetch($mailbox, $query, array('ids' => $uids));
$results = [];
foreach($messages as $message){
$envelope = $message->getEnvelope();
$structure = $message->getStructure();
$msghdr = new StdClass;
$msghdr->recipients = $envelope->to->bare_addresses;
$msghdr->senders = $envelope->from->bare_addresses;
$msghdr->cc = $envelope->cc->bare_addresses;
$msghdr->bcc = $envelope->bcc->bare_addresses;
$msghdr->subject = $envelope->subject;
$msghdr->timestamp = $envelope->date->getTimestamp();
$query = new Horde_Imap_Client_Fetch_Query();
$query->fullText();
$typemap = $structure->contentTypeMap();
foreach ($typemap as $part => $type) {
// The body of the part - attempt to decode it on the server.
$query->bodyPart($part, array(
'decode' => true,
'peek' => true,
));
$query->bodyPartSize($part);
}
$id = new Horde_Imap_Client_Ids($message->getUid());
$messagedata = $oClient->fetch($mailbox, $query, array('ids' => $id))->first();
$msgdata = new StdClass;
$msgdata->id = $id;
$msgdata->contentplain = '';
$msgdata->contenthtml = '';
$msgdata->attachments = array(
'inline' => array(),
'attachment' => array(),
);
$plainpartid = $structure->findBody('plain');
$htmlpartid = $structure->findBody('html');
foreach ($typemap as $part => $type) {
// Get the message data from the body part, and combine it with the structure to give a fully-formed output.
$stream = $messagedata->getBodyPart($part, true);
$partdata = $structure->getPart($part);
$partdata->setContents($stream, array('usestream' => true));
if ($part == $plainpartid) {
$msgdata->contentplain = $partdata->getContents();
} else if ($part == $htmlpartid) {
$msgdata->contenthtml = $partdata->getContents();
} else if ($filename = $partdata->getName($part)) {
$disposition = $partdata->getDisposition();
$disposition = ($disposition == 'inline') ? 'inline' : 'attachment';
$attachment = new StdClass;
$attachment->name = $filename;
$attachment->type = $partdata->getType();
$attachment->content = $partdata->getContents();
$attachment->size = strlen($attachment->content);
$msgdata->attachments[$disposition][] = $attachment;
}
}
$data = [
'uid' => implode("",$id->ids),
'from' => implode(",",$msghdr->senders),
'cc' => implode(",",$msghdr->cc),
'bcc' => implode(",",$msghdr->bcc),
'to' => implode(",",$msghdr->recipients),
'date' => $msghdr->timestamp,
'subject' => $envelope->subject,
'hasAttachments' => $structure->getDisposition(),
'folder' => $mailbox,
'messageId' => $envelope->message_id,
'attachment' => $msgdata->attachments
];
$data['body'] = empty($msgdata->contenthtml) ? $msgdata->contenttext: $msgdata->contenthtml;
array_push($results,$data);
}
$fetchQuery = new Horde_Imap_Client_Fetch_Query();
$fetchQuery->fullText();
/** #var Horde_Imap_Client_Fetch_Results $mail */
$results = $client->fetch('INBOX', $fetchQuery, ['ids' => new Horde_Imap_Client_Ids(11632)]);
var_dump($results->first()->getFullMsg());
i want to return data from a web services with php in one group json container. my below script gives me each of the data seperated like this
{"No":"01","Name":"JOSEPH"}{"No":"02","Name":"AMINU"}
But i wan it to return like this
[{"No":"01","Name":"JOSEPH","No":"02","Name":"AMINU"}]
below is my script
try{
$service = new NTLMSoapClient($pageURL);
$params = array('filter' => array(
array('Field' => 'District_Name', 'Criteria' => '')
),
'setSize' => 2); //setSize =0 will return all rows - Can cause performance issue with large results set!
$result = $service->ReadMultiple($params);
$resultSet = $result->ReadMultiple_Result->customer;
if (is_array($resultSet)) {
foreach($resultSet as $item) {
$data=array('No' => $item->No,'Name' => $item->Name);
echo json_encode($data);
}
}
else {
echo json_encode('record not found');
}
}
catch (Exception $e) {
echo "<hr><b>ERROR: SoapException:</b> [".$e."]<hr>";
echo "<pre>".htmlentities(print_r($service->__getLastRequest(),1))."</pre>";
}
Try you foreach with this.
try{
$service = new NTLMSoapClient($pageURL);
$params = array('filter' => array(
array('Field' => 'District_Name', 'Criteria' => '')
),
'setSize' => 2); //setSize =0 will return all rows - Can cause performance issue with large results set!
$result = $service->ReadMultiple($params);
$resultSet = $result->ReadMultiple_Result->customer;
if (is_array($resultSet)) {
$jsonArray = [];
foreach($resultSet as $item) {
$data = array('No' => $item->No,'Name' => $item->Name);
$jsonArray = array_merge($jsonArray, $data);
}
echo json_encode($jsonArray);
}
else {
echo json_encode('record not found');
}
}
catch (Exception $e) {
echo "<hr><b>ERROR: SoapException:</b> [".$e."]<hr>";
echo "<pre>".htmlentities(print_r($service->__getLastRequest(),1))."</pre>";
}
try{
$service = new NTLMSoapClient($pageURL);
$params = array('filter' => array(
array('Field' => 'District_Name', 'Criteria' => '')
),
'setSize' => 2); //setSize =0 will return all rows - Can cause performance issue with large results set!
$result = $service->ReadMultiple($params);
$resultSet = $result->ReadMultiple_Result->customer;
if (is_array($resultSet)) {
$data = array();
foreach($resultSet as $item) {
$data = $data + array('No' => $item->No,'Name' => $item->Name);
}
echo json_encode($data);
}
else {
echo json_encode('record not found');
}
}
catch (Exception $e) {
echo "<hr><b>ERROR: SoapException:</b> [".$e."]<hr>";
echo "<pre>".htmlentities(print_r($service->__getLastRequest(),1))."</pre>";
}
The code the developer put in our site has a bunch of express (non freight) service types. I only need to implement FedEx Freight rates into my website and the developer has ran off on me. Any help would be greatly appreciated.
if($cominfo[0]['companyNAME'] == "FedEx" && $rescar12[0]['login']!="" && $rescar12[0]['carpassword']!="" && $rescar12[0]['accountNUMBER']!="" && $rescar12[0]['accesskey']!="" && $rescar12[0]['meterkey']!=""){
/*$fedx_accountnumber = $rescar12[0]['accountNUMBER'];
$fedex_meterkey = $rescar12[0]['meterkey'];
$fedex_freightAccount = $rescar12[0]['meterkey'];
$fedex_accessKey = $rescar12[0]['meterkey'];
$fedex_productionPassword = $rescar12[0]['meterkey'];*/
echo '<pre>';
print_r($_SESSION['order']);
$fedx_accountnumber = 'account number';
$fedex_meterkey = 'meter key';
$fedex_freightAccount = 'freight account';
$fedex_accessKey = 'secret access key';
$fedex_productionPassword = 'secret password';
//$services1['fedex']['STANDARDOVERNIGHT'] = 'Standard Overnight';
if($_SESSION['order'][$counter]['weight_unit'] != "lb"){
$weight= convert_weight($_SESSION['order'][$counter]['weight'],$_SESSION['order'][$counter]['weight_unit'],'lb');
$weight_units = 'LB';
} else{
$weight = $_SESSION['order'][$counter]['weight'] ;
$weight_units = $_SESSION['order'][$counter]['weight_unit'];
}
// Services
$services = $services1;
// Weight
$weight = $_SESSION['order'][$counter]['weight']; // Default = 1
$weight_units = $_SESSION['order'][$counter]['weight_unit']; // lb (default), oz, gram, kg
// Size
$size_length = $_SESSION['order'][$counter]['len_gth']; // Default = 8
$size_width = $_SESSION['order'][$counter]['width']; // Default = 4
$size_height = $_SESSION['order'][$counter]['height']; // Default = 2
$size_units = $_SESSION['order'][$counter]['dimesions']; // in (default), feet, cm
$role = $_SESSION['order'][$counter]['role'];
// From
$from_zip = $_SESSION['order'][$counter]['f_zipcode'];
$from_state = $_SESSION['order'][$counter]['f_stateID']; // Only Required for FedEx
$from_country = $_SESSION['order'][$counter]['f_countryID'];
$from_city = $_SESSION['order'][$counter]['f_cityID'];
// To
$to_zip = $_SESSION['order'][$counter]['t_zipcode'];
$to_state = $_SESSION['order'][$counter]['t_stateID']; // Only Required for FedEx
$to_country = $_SESSION['order'][$counter]['t_countryID'];
$to_city = $_SESSION['order'][$counter]['t_cityID'];
require_once "library/fedex-common.php";
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "wsdl/RateService_v14.wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array(
'UserCredential' =>array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
$request['ClientDetail'] = array(
'AccountNumber' => getProperty('shipaccount'),
'MeterNumber' => getProperty('meter')
);
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request v14 using PHP ***');
$request['Version'] = array(
'ServiceId' => 'crs',
'Major' => '14',
'Intermediate' => '0',
'Minor' => '0'
);
$request['ReturnTransitAndCommit'] = true;
$request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP'; // valid values REGULAR_PICKUP, REQUEST_COURIER, ...
$request['RequestedShipment']['ShipTimestamp'] = date('c');
$request['RequestedShipment']['ServiceType'] = 'FEDEX_FREIGHT_ECONOMY'; // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
$request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
$request['RequestedShipment']['Shipper'] = getProperty('freightbilling');
$request['RequestedShipment']['Recipient'] = addRecipient();
$request['RequestedShipment']['ShippingChargesPayment'] = addShippingChargesPayment();
$request['RequestedShipment']['FreightShipmentDetail'] = array(
'FedExFreightAccountNumber' => getProperty('freightaccount'),
'FedExFreightBillingContactAndAddress' => getProperty('freightbilling'),
'Role' =>$role,
'PaymentType' => 'PREPAID',
'LineItems' => array(
'FreightClass' => 'CLASS_0'.$_SESSION['order'][$counter]['class'],
'Weight' => array(
'Value' => $weight,
'Units' => $weight_units,
),
'Dimensions' => array(
'Length' => $size_length,
'Width' => $size_width,
'Height' => $size_height,
'Units' => $size_units
),
)
);
$request['RequestedShipment']['RateRequestTypes'] = 'ACCOUNT';
$request['RequestedShipment']['RateRequestTypes'] = 'LIST';
$request['RequestedShipment']['PackageCount'] = '1';
try{
if(setEndpoint('changeEndpoint')){
$newLocation = $client->__setLocation(setEndpoint('endpoint'));
}
$response = $client -> getRates($request);
echo '<pre>';
print_r($response);
exit;
if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR'){
echo $rateReply = $response -> RateReplyDetails->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount;
// printSuccess($client, $response);
}else{
echo $rateReply ='N/A';
//printError($client, $response);
}
//writeToLog($client); // Write to log file
} catch (SoapFault $exception) {
printFault($exception, $client);
}
$_SESSION['FedEx'][$counter]['price'] = $rateReply;
}
Merged with multicheckboxes zend form multi populate.
i did do the form with multicheckboxs and it works fine when insert or update but the my problem is how to populate all the multi boxes that is checked form the database this is the code but it doesn't show just one checkbox is checked
$id = (int) $this->_request->getParam('id');
//The incoming request
$request = $this->getRequest();
//initialize form
$form = new Admin_Form_DownFooterTab();
//instance of db
$db = Zend_Db_Table::getDefaultAdapter();
if ($this->getRequest()->isPost()) {
if ($form->isValid($request->getPost())) {
if (isset($id) && $id != "") {
$gettag = $form->getValue('tag_id');
$gettags = count($gettag);
try {
//shift the orders to
$select = $db->select()->from(array('t' => 'tab'), array('t.id',
't.title',
't.tab_position',
't.order',
't.is_active',
't.is_deleted'))->where('id = ?', $id);
$currentTab = $db->fetchRow($select);
$var3 = array('tab.order' => new Zend_Db_Expr('tab.order - 1'));
$var4 = array('tab.order >= ' . $currentTab['order'], 'is_active=1', 'is_deleted=0', 'tab_position=4');
$db->update('tab', $var3, $var4);
$var = array('tab.order' => new Zend_Db_Expr('tab.order + 1'));
$var2 = array('tab.order >= ' . $form->getValue('order'), 'is_active=1', 'is_deleted=0', 'tab_position=4');
$db->update('tab', $var, $var2);
$db->delete('tab_tag', array('tab_id = ?' => $id));
foreach ($gettag as $value) {
$db->insert('tab_tag',
array(
'tag_id' => $value,
'tab_id' => $id
));
}
$db->update('tab', array(
'title' => $form->getValue('title'),
'body' => $form->getValue('body'),
'is_active' => $form->getValue('is_active'),
'banner_link' => $form->getValue('banner_link'),
'tab_path' => $form->getValue('tab_path'),
'link_open' => $form->getValue('link_open'),
'tab_position' => $form->getValue('tab_position'),
'tab_parent' => $form->getValue('tab_parent')
),
array('id =?' => $id));
$this->flash('Tab Updated', 'admin/tab');
} catch (Exception $e) {
$this->flash($e->getMessage(), 'admin/tab');
}
} else {
try {
$formValues = $form->getValues();
$formValues['created_by'] = 1;
$formValues['created_date'] = date('Y/m/d H:i:s');
$formValues['is_deleted'] = 0;
$var = array('tab.order' => new Zend_Db_Expr('tab.order + 1'));
$var2 = array('tab.order >= ' . $form->getValue('order'), 'is_active=1', 'is_deleted=0', 'tab_position=4');
$db->update('tab', $var, $var2);
foreach ($gettag as $value) {
$db->insert('tab_tag',
array(
'tag_id' => $value,
'tab_id' => $id
));
}
$db->insert('tab', array(
'title' => $form->getValue('title'),
'body' => $form->getValue('body'),
'is_active' => $form->getValue('is_active'),
'banner_link' => $form->getValue('banner_link'),
'tab_path' => $form->getValue('tab_path'),
'link_open' => $form->getValue('link_open'),
'tab_position' => $form->getValue('tab_position'),
'tab_parent' => $form->getValue('tab_parent')
));
$this->flash('Tab inserted', 'admin/tab');
} catch (Exception $e) {
$this->flash($e->getMessage(), 'admin/tab');
}
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
if (isset($id) && $id != "") {
$values = $db->fetchRow("SELECT * FROM tab WHERE id = ?", $id);
$form->populate($values);
}
$this->view->form = $form;
}
$ddlCat_parent->setMultiOptions($cats);
$this->view->form = $form;
}