Skip to content

Instantly share code, notes, and snippets.

View jasp402's full-sized avatar

jasp402 jasp402

View GitHub Profile
@jasp402
jasp402 / convert_SPC5_to_BitrixId.php
Last active July 24, 2017 12:18
PHP - Bitrix (Return a ID of Client inside Bitrix. Set parameter SPC5 of Account Number)
\CModule::IncludeModule("crm");
$resultClient = \CCrmCompany::GetList(array(),array("UF_CRM_1493986539" => 15012));
$client = $resultClient->fetch();
return $client;
@jasp402
jasp402 / convert_BitrixId_to_SPC5.php
Created July 20, 2017 18:33
PHP - Bitrix (Return the SPC5 of Client inside Bitrix. Set parameter ID used in Bitrix of Account)
\CModule::IncludeModule("crm");
$resultClient = \CCrmCompany::GetList(array(),array("ID" => 12, "CHECK_PERMISIONS"=>"N"));
$client = $resultClient->fetch();
$result = $client["UF_CRM_1493986588"];
echo $result;
@jasp402
jasp402 / format_date.php
Last active August 8, 2017 18:29
PHP - Bitrix (Generic format date )
$BxDate = date("m/d/Y", strtotime($fecha)); //Bitrix Date
$BxDate = date("m-d-Y h:i:s", strtotime($fecha)); //Bitrix DateTime
$BxDate = date("m-d-Y", strtotime($fecha)); //SQL Date
$BxDate = date("Ymdhis", strtotime("now")); //Current day for random Date
/* Date inside Business Process */
//{=System:Now}
@jasp402
jasp402 / utils.php
Last active July 24, 2017 13:36
PHP - Bitrix (Call function from class ServerBots::Utils )
//Consultar el ultimo dia de ejecucion
\CModule::IncludeModule("codisoti.serverbots");
use Codisoti\ServerBots\Utils;
$obj = new Utils();
$result = $obj->getLastExecutionByPortalDetail(885,32);
//----------------------------------------------------------------------------------------------------
//actualizar la ultima execution
@jasp402
jasp402 / clear_fields.php
Last active July 25, 2017 15:18
PHP - Bitrix (Clear fields, get list since infoBlock and set field name want clear)
CModule::IncludeModule("iblock");
$ob=CIblockElement::GetList(
array(),
array("IBLOCK_ID"=>62, "PROPERTY_PORTAL" =>885),
false,
false,
array("ID","PROPERTY_LAST_EXECUTION"));
while ($res = $ob->GetNextElement()) {
$arFields = $res->GetFields();
@jasp402
jasp402 / utils-assignLastExecutionByClient.php
Created July 25, 2017 12:53
PHP - Bitrix (function for assign last execution of the bots. set parameters portal_id, array of client and archeck_date)
function assignLastExecutionByClient($portal_id,$arClientId,$arCheckDate){
if(isset($arClientId) && count($arClientId)>0){
foreach ($arClientId as $key => $value) {
$ElementPortalDetail = $utils->getLastExecutionByPortalDetail($portal_id,$value);
$elementId = $ElementPortalDetail["id"];
$checkDate = (max($arCheckDate[$value]));
$lastExecutionBot = date("m/d/Y",strtotime($checkDate["checkDate"]));
$lastExecutionPortal = date("m/d/Y",strtotime($ElementPortalDetail['last_execution']));
@jasp402
jasp402 / sendDataToServer_method_Sync.js
Created August 1, 2017 18:57
JS - Bot's (Sending data to server using Sync-request)
// Seding data through sync-request
// ========================================================================
let sendServer = request('POST', key.serverUrl,
{
headers: {'content-type': 'application/x-www-form-urlencoded'},
body : 'username=' + key.username + '&password=' + key.password + '&botName=cigna&request=save&data='+objsToServer
});
let responseBody = sendServer.getBody();
console.log(responseBody.toString());
@jasp402
jasp402 / uDateYesterday()
Created February 1, 2018 14:19
AutoIT - Día anterior
#include <Date.au3>
Func uDateYesterday()
$yesterday = _DateAdd("d", -1, _NowCalcDate())
$arDate = StringSplit($yesterday, "/")
$sDate_New = $arDate[2] & "/" & $arDate[3] & "/" & $arDate[1]
;~ $sDate_New = $aDate[3] & " " & $aDate[2] & " " & StringRight($aDate[1],2)
;~ MsgBox(0, "Date", "Yesterday is "& $sDate_New)
Return $sDate_New
EndFunc
@jasp402
jasp402 / findWndTitle()
Last active February 8, 2018 21:54
AutoIT - Buscar titulo de una Ventana
Func findWndTitle($sTitle)
Sleep(2000)
Local $hTitle =''
Local $w_WinList = WinList()
For $i = 1 to $w_WinList[0][0]
If $w_WinList[$i][0] <> "" _
AND BitAnd(WinGetState($w_WinList[$i][1]), 2) _
AND StringInStr($w_WinList[$i][0], $sTitle) _
Then
$hTitle = $w_WinList[$i][0]
@jasp402
jasp402 / waitForExistFile()
Created February 12, 2018 14:06
AutoIT - Esperar hasta que el archivo exista
Func waitForExistFile($sPath, $iTimeOut)
$sBegin = TimerInit()
While TimerDiff($sBegin) < $iTimeOut
If FileExists($sPath) then
Return True
Else
ContinueLoop
EndIf
Return false
WEnd