public function outputStock($idProduct, $amount) { $product = $this->findById($idProduct); if (!is_nulL($product)) { $product->current_inventory -= $amount; try { $product->save(); return true; } catch (\Exception $e) { return false; } } return false; }
/** * @param string $apiServer The api server * @param string $apiPort The api port * @param string $apiPath The api path * @param string $apiFingerprint The api fingerprint * @param string $apiIdent The api ident * @param string $apiSecret The api secret * * @throws WebshopappApiException */ public function __construct($params = null) { if (!function_exists('curl_init')) { throw new MplusQAPIException_VersionTester('MplusQAPIclient_VersionTester needs the CURL PHP extension.'); } if (!function_exists('json_decode')) { throw new MplusQAPIException_VersionTester('MplusQAPIclient_VersionTester needs the JSON PHP extension.'); } if (!is_nulL($params)) { $this->setApiServer($params['apiServer']); $this->setApiPort($params['apiPort']); $this->setApiPath($params['apiPath']); $this->setApiFingerprint($params['apiFingerprint']); $this->setApiIdent($params['apiIdent']); $this->setApiSecret($params['apiSecret']); $this->initClient(); } $this->parser = new MplusQAPIDataParser_VersionTester(); }
public static function sendEmail($to, $from, $subject, $content, $cc = NULL, $bcc = NULL) { $settings = InternSettings::getInstance(); // Sanity checking if (!isset($to) || is_null($to)) { return false; } if (!isset($from) || is_null($from)) { $from = $settings->getSystemName() . ' <' . $settings->getEmailFromAddress() . '>'; } if (!isset($subject) || is_null($subject)) { return false; } if (!isset($content) || is_nulL($content)) { return false; } // Create a Mail object and set it up PHPWS_Core::initCoreClass('Mail.php'); $message = new PHPWS_Mail(); $message->addSendTo($to); $message->setFrom($from); $message->setSubject($subject); $message->setMessageBody($content); if (isset($cc)) { $message->addCarbonCopy($cc); } if (isset($bcc)) { $message->addBlindCopy($bcc); } // Send the message if (EMAIL_TEST_FLAG) { $result = true; } else { $result = $message->send(); } if (PEAR::isError($result)) { PHPWS_Error::log($result); return false; } self::logEmail($message); return true; }
public static function send_email($to, $from, $subject, $content, $cc = NULL, $bcc = NULL) { # Sanity checking if (!isset($to) || is_null($to)) { return false; } if (!isset($from) || is_null($from)) { $from = SYSTEM_NAME . ' <' . FROM_ADDRESS . '>'; } if (!isset($subject) || is_null($subject)) { return false; } if (!isset($content) || is_nulL($content)) { return false; } # Create a Mail object and set it up \PHPWS_Core::initCoreClass('Mail.php'); $message = new PHPWS_Mail(); $message->addSendTo($to); $message->setFrom($from); $message->setSubject($subject); $message->setMessageBody($content); if (isset($cc)) { $message->addCarbonCopy($cc); } if (isset($bcc)) { $message->addBlindCopy($bcc); } # Send the message if (EMAIL_TEST_FLAG) { HMS_Email::log_email($message); $result = true; } else { $result = $message->send(); } if (PEAR::isError($result)) { PHPWS_Error::log($result); return false; } return true; }