Example #1
0
 public function testHarmonise()
 {
     $export =& $this->export;
     $this->assertEquals("abcdefgh", $this->export->harmonise("abcdefghi", $export::ALPHA_NUMERIC, 8));
     $this->assertEquals("abcd    ", $this->export->harmonise("abcd", $export::ALPHA_NUMERIC, 8));
     $this->assertEquals("00008", $this->export->harmonise(8, $export::NUMERIC, 5));
     $this->assertEquals("4", $this->export->harmonise(42, $export::NUMERIC, 1));
     $this->assertEquals("4.0", $this->export->harmonise(4, $export::FLOAT, 3));
     $this->assertEquals("43.26", $this->export->harmonise(43.256, $export::FLOAT, 5));
     $this->assertEquals("123.25", $this->export->harmonise(123.254, $export::FLOAT, 6));
 }
 public function singleExport($order_id)
 {
     if (null !== ($response = $this->checkAuth([AdminResources::MODULE, AdminResources::ORDER], ['Predict'], AccessManager::VIEW))) {
         return $response;
     }
     $export = new PredictExport();
     $export_data = "";
     $order = OrderQuery::create()->findPk($order_id);
     if ($order === null) {
         throw new \InvalidArgumentException("order_id " . $order_id . " doesn't exist");
     }
     try {
         $form = new SingleExportForm($this->getRequest());
         $vform = $this->validateForm($form, "post");
         $export->addEntry(new ExportEntry($order, $vform->get("guaranty")->getData()));
         $export_data = $export->doExport();
     } catch (\Exception $e) {
         $this->redirectToRoute('admin.order.update.view', array("errmes" => $e->getMessage()), array("_controller" => 'Thelia\\Controller\\Admin\\OrderController::viewAction', "order_id" => $order_id, "tab" => "modules"));
     }
     return $this->createResponse($export_data);
 }
Example #3
0
 /**
  * @return boolean
  *                 Check if the export entry is valid
  */
 public function isValid()
 {
     /**
      * Get country
      */
     $country = $this->getDeliveryOrderCountry();
     /**
      * Do the checks
      */
     $checks = $this->order->getCustomer()->getDefaultAddress()->getCellphone() !== null;
     $checks &= PredictExport::translateCountry($country) !== null;
     return (bool) $checks;
 }