|
|
@@ -258,15 +258,14 @@ class Document extends ActiveRecordCommon |
|
|
|
{ |
|
|
|
$filenameComplete = $this->getFilenameComplete(); |
|
|
|
|
|
|
|
if(!file_exists($filenameComplete)) { |
|
|
|
if (!file_exists($filenameComplete)) { |
|
|
|
$this->generatePdf(Pdf::DEST_FILE); |
|
|
|
} |
|
|
|
|
|
|
|
if(file_exists($filenameComplete)) { |
|
|
|
return Yii::$app->response->sendFile($filenameComplete, $this->getFilename(), ['inline'=>true]); |
|
|
|
} |
|
|
|
else { |
|
|
|
throw new ErrorException('File '.$filenameComplete.' not found'); |
|
|
|
if (file_exists($filenameComplete)) { |
|
|
|
return Yii::$app->response->sendFile($filenameComplete, $this->getFilename(), ['inline' => true]); |
|
|
|
} else { |
|
|
|
throw new ErrorException('File ' . $filenameComplete . ' not found'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -396,25 +395,27 @@ class Document extends ActiveRecordCommon |
|
|
|
if ($ordersArray && count($ordersArray)) { |
|
|
|
foreach ($ordersArray as $order) { |
|
|
|
foreach ($order->productOrder as $productOrder) { |
|
|
|
$indexProductOrder = $productOrder->product->order; |
|
|
|
$newProductOrder = clone $productOrder; |
|
|
|
|
|
|
|
if (!isset($productsOrdersArray[$indexProductOrder])) { |
|
|
|
$productsOrdersArray[$indexProductOrder] = [$newProductOrder]; |
|
|
|
} else { |
|
|
|
$productOrderMatch = false; |
|
|
|
foreach ($productsOrdersArray[$indexProductOrder] as &$theProductOrder) { |
|
|
|
if ($theProductOrder->unit == $productOrder->unit |
|
|
|
&& ((!$this->isInvoicePrice() && $theProductOrder->price == $productOrder->price) |
|
|
|
|| ($this->isInvoicePrice() && $theProductOrder->invoice_price == $productOrder->invoice_price) |
|
|
|
)) { |
|
|
|
|
|
|
|
$theProductOrder->quantity += $productOrder->quantity; |
|
|
|
$productOrderMatch = true; |
|
|
|
if ($productOrder->product) { |
|
|
|
$indexProductOrder = $productOrder->product->order; |
|
|
|
$newProductOrder = clone $productOrder; |
|
|
|
|
|
|
|
if (!isset($productsOrdersArray[$indexProductOrder])) { |
|
|
|
$productsOrdersArray[$indexProductOrder] = [$newProductOrder]; |
|
|
|
} else { |
|
|
|
$productOrderMatch = false; |
|
|
|
foreach ($productsOrdersArray[$indexProductOrder] as &$theProductOrder) { |
|
|
|
if ($theProductOrder->unit == $productOrder->unit |
|
|
|
&& ((!$this->isInvoicePrice() && $theProductOrder->price == $productOrder->price) |
|
|
|
|| ($this->isInvoicePrice() && $theProductOrder->invoice_price == $productOrder->invoice_price) |
|
|
|
)) { |
|
|
|
|
|
|
|
$theProductOrder->quantity += $productOrder->quantity; |
|
|
|
$productOrderMatch = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!$productOrderMatch) { |
|
|
|
$productsOrdersArray[$indexProductOrder][] = $newProductOrder; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!$productOrderMatch) { |
|
|
|
$productsOrdersArray[$indexProductOrder][] = $newProductOrder; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -438,14 +439,14 @@ class Document extends ActiveRecordCommon |
|
|
|
|
|
|
|
public function getAliasDirectoryBase() |
|
|
|
{ |
|
|
|
return '@app/web/pdf/'.$this->id_producer.'/'; |
|
|
|
return '@app/web/pdf/' . $this->id_producer . '/'; |
|
|
|
} |
|
|
|
|
|
|
|
public function initDirectoryPdf() |
|
|
|
{ |
|
|
|
$aliasDirectoryBase = $this->getAliasDirectoryBase(); |
|
|
|
$directoryPdf = Yii::getAlias($aliasDirectoryBase); |
|
|
|
if(!file_exists($directoryPdf)) { |
|
|
|
if (!file_exists($directoryPdf)) { |
|
|
|
mkdir($directoryPdf, 0755); |
|
|
|
} |
|
|
|
} |