Location: PHPKode > scripts > PHPMass Shopping Cart > phpmass-shopping-cart/user/companies.php
<?php
/******************************************************************
 * PHPMass Shopping Cart
 * The contents of this file are subject to the PHPMass License. 
 * If you do not agree with PHPMass License Terms and Conditions 
 * than you should not use this software.
 * A copy of the license file is available on www.phpmass.com/license.htm page.
 * 
 * PHPMass.com.
 * All Rights Reserved.
 ******************************************************************/
$SiteSection = 'user';
require('../includes/config.php');
// Cart and top products
$LastProducts = $Carts->getLastProducts();
if (is_array($LastProducts)) {
	$LastProduct = array_shift($LastProducts);
}
$smarty->assign('LastProduct', $LastProduct);
$smarty->assign('LastProducts', $LastProducts);

$TopProducts = $Categories->getTopProducts(0,false,true);
$smarty->assign('TopProducts', $TopProducts);

if (isset($_POST['updateCompany'])) {
	if (!hasLength(trim($_POST['companyName']),4,50)) $Error['CompanyName_NotValid'] = $Lang['CompanyName_NotValid'];
	if (!hasLength(trim($_POST['companyDetails']),4,255)) $Error['CompanyDetails_NotValid'] = $Lang['CompanyDetails_NotValid'];
	if (count($Error) == 0) {
		$Users->updateCompanyID($userid,$_POST['companyId'],trim($_POST['companyName']),trim($_POST['companyDetails']));
		$InfoMessage['companyUpdated'] = $Lang['Company_Updated'];
	}
}
elseif (isset($_POST['newCompany'])) {
	if (!hasLength(trim($_POST['companyName']),4,50)) $Error['CompanyName_NotValid'] = $Lang['CompanyName_NotValid'];
	if (!hasLength(trim($_POST['companyDetails']),4,255)) $Error['CompanyDetails_NotValid'] = $Lang['CompanyDetails_NotValid'];
	if (count($Error) == 0) {
		$Users->newCompany($userid,trim($_POST['companyName']),trim($_POST['companyDetails']));
		$InfoMessage['companyInserted'] = $Lang['Company_Inserted'];
	}
}
elseif (isset($_GET['deleteCompany'])) {
	$Users->deleteCompany($userid,$_GET['deleteCompany']);
	$InfoMessage['companyDeleted'] = $Lang['Company_Deleted'];
}

if (isset($_GET['modifyCompany'])) {
	$SelectedCompany = $Users->getCompanyByID($userid,$_GET['modifyCompany']);
	$smarty->assign('SelectedCompany', $SelectedCompany);
}
else {

}
$UserCompanies = $Users->getCompanies($userid);
$smarty->assign('UserCompanies', $UserCompanies);

$smarty->assign('PageTitle', $Lang['Companies']);
$smarty->assign('Error', $Error);
$smarty->assign('InfoMessage', $InfoMessage);

$smarty->display(DOC_ROOT.'/skin/templates/user/'.'companies.tpl');

?>
Return current item: PHPMass Shopping Cart