//
// This code is open source and may be copied and modified as long as the source
// code is always made freely available.
// Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
//====================================================================================
require 'require/function_telediff.php';
//you can delete all packets if status=NOTIFIED and date>3 mounths
if (isset($protectedGet['reset_notified']) and is_numeric($protectedGet['reset_notified'])) {
    desactive_packet($systemid, $protectedGet['reset_notified']);
}
//affect again a packet
if ($protectedPost['Valid_modif_x']) {
    if (trim($protectedPost['MOTIF'])) {
        if ($protectedPost["ACTION"] == "again") {
            //delete all info of specific teledeploy
            desactive_download_option($systemid, $protectedGet['affect_again']);
            active_option('DOWNLOAD', $systemid, $protectedGet['affect_again']);
        } elseif ($protectedPost["ACTION"] == "reset") {
            desactive_packet($systemid, $protectedGet['affect_reset']);
        }
        mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg);
        if (mysql_affected_rows() != 0) {
            $sql = "INSERT INTO itmgmt_comments (hardware_id,comments,user_insert,date_insert,action) \n\t\t\t\t\tvalues ('%s','%s','%s',%s,'%s => %s')";
            $arg = array($systemid, $protectedPost['MOTIF'], $_SESSION['OCS']["loggeduser"], "sysdate()", $protectedPost["ACTION"], $protectedPost['NAME_PACK']);
            mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg);
        }
    } else {
        msg_error($l->g(903));
    }
}
if ($protectedPost['Reset_modif_x']) {
function desactive_packet($list_id, $packid)
{
    desactive_download_option($list_id, $packid);
    $nb_line = desactive_option('DOWNLOAD', $list_id, $packid);
    return $nb_line;
}