mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Eliminado mecanismo de pasar a XML pedido
This commit is contained in:
@ -15,52 +15,23 @@ class SafekatFtpClient
|
||||
protected string $username;
|
||||
protected string $password;
|
||||
protected string $base_dir;
|
||||
protected bool $xml_enabled;
|
||||
protected object $pedido_xml_config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->pedido_xml_config = config("PedidoXML");
|
||||
$this->pedido_xml_config = config("PresupuestoSFTP");
|
||||
$this->host = $this->pedido_xml_config->host;
|
||||
$this->username = $this->pedido_xml_config->username;
|
||||
$this->password = $this->pedido_xml_config->password;
|
||||
$this->port = $this->pedido_xml_config->port;
|
||||
$this->base_dir = $this->pedido_xml_config->base_dir;
|
||||
$this->xml_enabled = $this->pedido_xml_config->xml_enabled;
|
||||
$this->ftp = new SFTP($this->host);
|
||||
|
||||
}
|
||||
/**
|
||||
* Upload the content of $filename to the base directory declared in App\Config\FTP.php
|
||||
*
|
||||
* @param string $content
|
||||
* @param string $filename
|
||||
* @return boolean
|
||||
*/
|
||||
public function uploadXML(string $content, string $filename): bool
|
||||
{
|
||||
try {
|
||||
if ($this->xml_enabled == false)
|
||||
return false;
|
||||
$remotePath = implode("/", [$this->base_dir, 'pedidos', 'xml_nuevos']);
|
||||
$this->ftp->login(username: $this->username, password: $this->password);
|
||||
if (!$this->ftp->is_dir($remotePath)) {
|
||||
$this->ftp->mkdir($remotePath, recursive: true);
|
||||
}
|
||||
$this->ftp->put($remotePath . '/' . $filename, $content);
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $th) {
|
||||
throw $th;
|
||||
log_message('error', $th->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public function uploadFilePresupuesto(int $presupuesto_id)
|
||||
{
|
||||
try {
|
||||
if ($this->xml_enabled == false)
|
||||
return false;
|
||||
$model = model(PresupuestoFicheroModel::class);
|
||||
$modelPedidoLinea = model(PedidoLineaModel::class);
|
||||
$pedidoLinea = $modelPedidoLinea->findByPresupuesto($presupuesto_id);
|
||||
@ -86,7 +57,6 @@ class SafekatFtpClient
|
||||
public function removeFiles(int $presupuesto_id)
|
||||
{
|
||||
try {
|
||||
// if ($this->xml_enabled == false) return false;
|
||||
$model = model(PresupuestoFicheroModel::class);
|
||||
$modelPedidoLinea = model(PedidoLineaModel::class);
|
||||
$pedidoLinea = $modelPedidoLinea->findByPresupuesto($presupuesto_id);
|
||||
|
||||
Reference in New Issue
Block a user