=2) { $paydef = 1; } else { $paydef = 0; } switch($versiontype) { case 1: $prod = 'MG BASIC RENEW'; break; case 2: $prod = 'MG PRO DEMO PURCHASE'; break; case 3: $prod = 'MG PRO RENEW'; break; default: $prod = 'MG DEMO PURCHASE'; break; } if (($licenseid == 0) and ($expiredate == '')) { // Abort if invalid GET parameters echo '

Page not found

'; echo '

The requested page "/products/mg/renew" could not be found.

'; } else { // Instantiate the HTML_QuickForm2 object $form = new HTML_QuickForm2('renewalform','post',array('action'=>strip_tags($_SERVER['REQUEST_URI']),'accept-charset'=>"utf-8")); // Set defaults for the form elements $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array( 'BillName'=>$company, 'BillAddress'=>$address, 'BillAtt'=>$attention, 'PayMeth' => $paydef, 'Product' => $prod, 'LicenseNr' => $licenseid, 'SalesOffice' => $officeid, 'Expires' => $expiredate ))); // Add hidden fields $form->addElement('hidden', 'Product'); $form->addElement('hidden', 'LicenseNr'); $form->addElement('hidden', 'SalesOffice'); $form->addElement('hidden', 'Expires'); // Add billing info fieldset $bill = $form->addFieldset('billinginfo')->setLabel('Your billing address'); $name = $bill->addText('BillName', array('size' => 50, 'maxlength' => 255))->setLabel('Bill to (payer name):'); $addr = $bill->addTextArea('BillAddress',array('class'=>'form-textarea', cols=>49, rows=>4))->setlabel('Billing address'); $pers = $bill->addText('BillAtt', array('size' => 50, 'maxlength' => 255))->setlabel('Contact person'); // Add payment method fieldset $mtd = $form->addFieldset('paymentinfo')->setLabel('Select a payment method for renewal'); if ($versiontype < 2) { $mtd->addRadio('PayMeth',array('value'=>0),array('content' => 'CreditCard', 'label' => 'Payment method:')); if (($companyid > 0) and (($officeid == 1) or ($officeid == 3))) { $mtd->addRadio('PayMeth',array('value'=>1),array('content' => 'Invoice', 'label' => ' ')); } } else { $mtd->addRadio('PayMeth',array('value'=>1),array('content' => 'Invoice', 'label' => 'Payment method:')); } $form->addSubmit('submit', array('value' => 'Renew now', 'id' => 'submit')); // Define filters and validation rules $name->addFilter('trim'); $name->addRule('required', 'A payer name is required'); $addr->addFilter('trim'); $addr->addRule('required', 'A billing address is required'); $pers->addFilter('trim'); // Try to validate a form if ($form->validate()) { $vals = $form->getValue(); switch($vals['PayMeth']) { case 1: $pay = 'Invoice'; break; default: $pay = 'Credit Card'; break; } $msg = "LicenseNr={$vals['LicenseNr']}\n" . "SalesOfficeID={$vals['SalesOffice']}\n" . "Expires={$vals['Expires']}\n" . "BillCompany={$vals['BillName']}\n" . "BillAddress={$vals['BillAddress']}\n" . "BillAtt={$vals['BillAtt']}\n" . "PaymentMethod=" . $pay . "\n" . "Product={$vals['Product']}\n"; $msg = utf8_decode($msg); $lic = "{$vals['LicenseNr']}"; $lic = utf8_decode($lic); $att = "{$vals['Expires']}" . $pay . "({$vals['SalesOffice']})"; $att = utf8_decode($att); $pro = "{$vals['Product']}"; $pro = utf8_decode($pro); try { $dbh = new PDO('mysql:host=localhost;dbname=web_stat', "macaos", "web"); $stmt = $dbh->prepare("INSERT INTO bestilling (msg, address, att, dato, product) " . "VALUES (:msg, :lic, :att, :dato, :pro)"); $stmt->bindParam(':msg', $msg); $stmt->bindParam(':lic', $lic); $stmt->bindParam(':att', $att); $stmt->bindParam(':pro', $pro); $stmt->bindParam(':dato', time()); $stmt->execute(); $dbh = null; } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "
"; die(); } switch($vals['PayMeth']) { case 1: echo "
Thank you for purchasing Macaos Gallery, your purchase will be processed within 2 working days!
"; break; default: if ($versiontype ==0) { header("location:http://buy.macaos.com/products/macaos-gallery"); exit; } else { header("location:http://buy.macaos.com/products/macaos-gallery-renewal"); exit; } } } else { echo '

Your '; switch($versiontype) { case 1: echo 'period of free upgrades to Macaos Gallery'; break; case 3: echo 'license to Macaos Gallery Pro'; break; default: echo 'Macaos Gallery evaluation period'; break; } echo ' will expire on ',$expiredate,'

'; // Render the form $renderer = HTML_QuickForm2_Renderer::factory('default') ->setOption(array( 'group_hiddens' => true, 'group_errors' => true, 'required_note' => 'Note: Required fields are marked with an asterisk (*).' )) ->setTemplateForId('submit', '
{element} or Cancel
') ->setTemplateForClass( 'HTML_QuickForm2_Element_Input', '
{error}' . '' . '{element}' . '
{label_2}
') ->setTemplateForClass( 'HTML_QuickForm2_Element_InputRadio', '
{error}' . '' . '{element}
') ->setTemplateForClass( 'HTML_QuickForm2_Element_TextArea', '
{error}' . '' . '{element}' . '{label_2}
') ->setTemplateForId('qfauto-1', '
'. 'Select a payment method for renewal{content}'. '
 
'); echo $form->render($renderer); // echo $form; } echo '

For more info contact us at support@macaos.com

'; } ?>