AHA download now uses correct Rimo API key
This commit is contained in:
@@ -903,6 +903,30 @@ class Preorder extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
public function getNetowner() {
|
||||
if(!$this->id) return false;
|
||||
if(!$this->adb_hausnummer_id) return false;
|
||||
$network = $this->getProperty("campaign")->network;
|
||||
$this->log->debug(__METHOD__.": campaign: ".$this->getProperty("campaign")->name);
|
||||
$this->log->debug(__METHOD__.": network: ".$network->name);
|
||||
if(!$network) return false;
|
||||
|
||||
return $network->owner;
|
||||
}
|
||||
|
||||
public function getNetownerRimoApiCredentials() {
|
||||
$netowner = $this->getNetowner();
|
||||
if(!$netowner) return false;
|
||||
|
||||
foreach(TT_RIMO_API_CREDS as $api_creds) {
|
||||
if($api_creds["address_id"] == $netowner->id) {
|
||||
return $api_creds;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function createUcode() {
|
||||
$ucode = $this->generateNewUcode();
|
||||
while(PreorderModel::search(['ucode' => $ucode])) {
|
||||
|
||||
@@ -846,7 +846,7 @@ class PreorderBillingInvoiceController extends mfBaseController {
|
||||
if(!array_key_exists($position->article_number, $kostentraeger)) {
|
||||
$kostentraeger[$position->article_number] = 0;
|
||||
}
|
||||
$kostentraeger[$position->article_number] += $position->price_gross;
|
||||
$kostentraeger[$position->article_number] += $position->price_total;
|
||||
}
|
||||
|
||||
$invoice_date = new DateTime($invoice->invoice_date);
|
||||
|
||||
@@ -875,6 +875,10 @@ class PreordercampaignController extends mfBaseController {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($preorder->status->code == 20) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$preorder->adb_wohneinheit_id) {
|
||||
//echo "Keine Wohneinheit in Preorder (".$preorder->id.") ".$preorder->ucode." ".$preorder->oaid."\n";
|
||||
$missing_units[] = $preorder;
|
||||
|
||||
@@ -37,12 +37,21 @@ class RimoWorkorder extends mfBaseModel {
|
||||
|
||||
public function getAha() {
|
||||
if(!$this->id) return false;
|
||||
if(!$this->adb_wohneinheit_id) return false;
|
||||
|
||||
$ah = Rimoapi::getWorkorderAhaReport($this->rimo_id);
|
||||
$preorder = PreorderModel::getFirstActive(["adb_wohneinheit_id" => $this->adb_wohneinheit_id]);
|
||||
$this->log->debug(__METHOD__.": Wohneinheit: ".$this->adb_wohneinheit_id);
|
||||
$this->log->debug(__METHOD__.": Preorder: ".$preorder->id);
|
||||
if(!$preorder) return false;
|
||||
|
||||
$api_creds = $preorder->getNetownerRimoApiCredentials();
|
||||
$this->log->debug(__METHOD__.": Rimo Api Creds: ".print_r($api_creds, true));
|
||||
if(!$api_creds) return false;
|
||||
|
||||
$apikey = $api_creds["prod"]["key"];
|
||||
$ah = Rimoapi::getWorkorderAhaReport($apikey, $this->rimo_id);
|
||||
|
||||
return $ah;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
|
||||
@@ -288,7 +288,7 @@ class Rimoapi {
|
||||
return $resp_data;
|
||||
}
|
||||
|
||||
public static function getWorkorderAhaReport($rimo_id) {
|
||||
public static function getWorkorderAhaReport($apikey, $rimo_id) {
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
if(!$rimo_id) {
|
||||
@@ -296,7 +296,7 @@ class Rimoapi {
|
||||
return false;
|
||||
}
|
||||
|
||||
$items = self::getFilenames($rimo_id);
|
||||
$items = self::getFilenames($apikey, $rimo_id);
|
||||
|
||||
if(!is_object($items)) {
|
||||
return false;
|
||||
@@ -321,7 +321,7 @@ class Rimoapi {
|
||||
// fetch file
|
||||
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
$params['apiKey'] = $apikey;
|
||||
$params['objectId'] = $rimo_id;
|
||||
$params['fileNames'] = $filename;
|
||||
|
||||
@@ -396,13 +396,13 @@ class Rimoapi {
|
||||
return $filecontent;
|
||||
}
|
||||
|
||||
public static function getFilenames($rimo_id) {
|
||||
public static function getFilenames($apikey, $rimo_id) {
|
||||
if(!$rimo_id) return false;
|
||||
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
$params['apiKey'] = $apikey;
|
||||
$params['objectId'] = $rimo_id;
|
||||
|
||||
$ctx_opts = [
|
||||
|
||||
Reference in New Issue
Block a user