*
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to info@easymarketing.de so we can send you a copy immediately.
 *
 * @author    silbersaiten www.silbersaiten.de <*****@*****.**>
 * @copyright 2015 Mediafinanz
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 */
require dirname(__FILE__) . '/../../config/config.inc.php';
require_once _PS_ROOT_DIR_ . '/init.php';
require_once dirname(__FILE__) . '/mediafinanz.php';
if (Tools::isPHPCLI() && isset($argc) && isset($argv)) {
    Tools::argvToGET($argc, $argv);
}
if (Tools::getValue('secure_key') != Configuration::getGlobalValue('MEDIAFINANZ_SECURE_KEY')) {
    die('Secure key is wrong');
} else {
    $module = new Mediafinanz();
    $return = true;
    $return &= $module->sendReminders();
    $log_type = 'cron';
    $message = 'Return: ' . print_r($return, true);
    Mediafinanz::logToFile($message, $log_type);
}
 public function renderView()
 {
     if (Tools::getValue('id_mf_new_message')) {
         $mf_message = new MediafinanzNewMessage((int) Tools::getValue('id_mf_new_message'));
         if (Validate::isLoadedObject($mf_message)) {
             $claim_object = MediafinanzClaim::getMediafinanzClaimByOrderId($mf_message->id_order);
         } else {
             $claim_object = new MediafinanzClaim();
         }
     } else {
         $claim_object = new MediafinanzClaim(Tools::getValue('id_mf_claim'));
     }
     if (!Validate::isLoadedObject($claim_object)) {
         $this->errors[] = $this->l('The claim cannot be found within your database.');
     }
     try {
         $claim_details = $this->module->getClaimDetails($claim_object);
         $claim_history = $this->module->getClaimHistory($claim_object->file_number);
         $claim_message_history = $this->module->getMessageHistory($claim_object->file_number);
         $claim_options = $this->module->getClaimOptions($claim_object->file_number);
     } catch (Exception $e) {
         $this->errors[] = $e->getMessage();
         Mediafinanz::logToFile($e->getMessage(), 'general');
     }
     if (in_array('close', $claim_options)) {
         $claim_options[] = 'bookDirectPayment';
     }
     // add form for direct payment
     //remove actions from this version of module
     $remove_options = array('lawyer', 'factoring', 'longTermObservation', 'addressIdentification');
     $claim_options = array_values(array_diff($claim_options, $remove_options));
     $this->context->smarty->assign('claim_details', $claim_details);
     $this->context->smarty->assign('claim_history', $claim_history);
     $this->context->smarty->assign('claim_options', $claim_options);
     $this->context->smarty->assign('claim_message_history', $claim_message_history);
     $this->context->smarty->assign('instructions_for_assigning', $this->module->getInstructionsForAssigningClaimToLawyer());
     $this->context->smarty->assign('mission_depthes', $this->module->getMissionDepthes());
     $this->setTemplate('claim-view' . (_PS_VERSION_ < '1.6.0.0' ? '_15' : '') . '.tpl');
 }