Rev 4084 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/bashif [ $# -lt 3 ]thenecho "Usage: $0 <from> <passwd> <email> [<email> ...]"exit 1fi# resolve links - $0 may be a softlinkPRG="$0"while [ -h "$PRG" ]; dols=`ls -ld "$PRG"`link=`expr "$ls" : '.*-> \(.*\)$'`if expr "$link" : '/.*' > /dev/null; thenPRG="$link"elsePRG=`dirname "$PRG"`/"$link"fidone# Get standard environment variablesPRGDIR=`dirname $(readlink -f "$PRG")`PYTHON_DIR="${PRGDIR}/../PyProj/src/shop2020/utils"DATE=`date +%Y-%b-%d`#Email the two report files.FROM=$1PASSWD=$2shift 2TO_LIST=""while (( "$#" ))doTO_LIST="${TO_LIST} -t $1"shiftdoneHOST="192.168.190.114"#HOST="localhost"mysql -uroot -pshop2020 -h ${HOST} catalog -e "select i.brand as 'Brand', (case i.model_name when null then ' ' else i.model_name end) as 'Model Name', i.model_number as 'Model Number', (case i.color when null then ' ' else i.color end) as 'Color', sum(c.availibility) as 'Available', sum(c.reserved) as 'Pending', sum(c.reserved) - sum(c.availibility) as 'Required' from currentinventorysnapshot c, item i where c.item_id = i.id and c.reserved > 0 group by i.id order by i.brand, i.model_name, i.model_number, i.color" > /tmp/pending-orders.csv${PYTHON_DIR}/CsvToXlsConvertor.py -o /tmp/inventory-stock-required.${DATE}.xls /tmp/pending-orders.csvpython ${PYTHON_DIR}/EmailAttachmentSender.py -f ${FROM} -p ${PASSWD} ${TO_LIST} -s "Inventory Stock required by Spice Online Retail" -a /tmp/inventory-stock-required.${DATE}.xlsrm /tmp/inventory-stock-required.${DATE}.xls